NDEVR
API Documentation
Converter.h
1#pragma once
2#include "Base/Headers/Buffer.hpp"
3#include "Base/Headers/Matrix.hpp"
4#include <Eigen/Dense>
5#include "GraphOptimization/Headers/GeometricCamera.h"
6namespace cv
7{
8 class Mat;
9 template<typename _Tp>
10 class Point3_;
11}
12
13namespace Sophus
14{
15 template <class Scalar_, int Options>
16 class SE3;
17 template <class Scalar_, int Options>
18 class Sim3;
19}
20namespace NDEVR
21{
22 struct Sim3;
23 class SE3Quat;
30 {
31 public:
37
42 static SE3Quat toSE3Quat(const cv::Mat& cvT);
47 static SE3Quat toSE3Quat(const Sophus::SE3<float, 0>& T);
52 static SE3Quat toSE3Quat(const Sim3& gSim3);
53
58 static cv::Mat toCvMat(const SE3Quat& SE3);
63 static cv::Mat toCvMat(const Sim3& Sim3);
68 static cv::Mat toCvMat(const Eigen::Matrix<double, 4, 4>& m);
73 static cv::Mat toCvMat(const Eigen::Matrix<float, 4, 4>& m);
78 static cv::Mat toCvMat(const Eigen::Matrix<float, 3, 4>& m);
83 static cv::Mat toCvMat(const Eigen::Matrix<double, 3, 3>& m);
88 static cv::Mat toCvMat(const Eigen::Matrix<double, 3, 1>& m);
93 static cv::Mat toCvMat(const Eigen::Matrix<float, 3, 1>& m);
98 static cv::Mat toCvMat(const Eigen::Matrix<float, 3, 3>& m);
99
100
105 static Matrix<fltp04> ToNDVMat(const Eigen::Matrix<float, 4, 4>& m)
106 {
107 Matrix<fltp04> mat;
108 for (uint01 i = 0; i < 4; i++)
109 for (uint01 j = 0; j < 4; j++)
110 mat[j][i] = cast<fltp04>(m(i, j));
111 return mat;
112 }
113
118 static cv::Mat toCvMat(const Eigen::Matrix<float, -1, -1>& m);
123 static cv::Mat toCvMat(const Eigen::Matrix<double, -1, -1>& m);
124
130 static cv::Mat toCvSE3(const Eigen::Matrix<double, 3, 3>& R, const Eigen::Matrix<double, 3, 1>& t);
136 static cv::Mat toCvSE3(const Eigen::Matrix<fltp04, 3, 3>& R, const Eigen::Matrix<fltp04, 3, 1>& t);
141 static cv::Mat tocvSkewMatrix(const cv::Mat& v);
142
147 static Eigen::Matrix<double, 3, 1> toVector3d(const cv::Mat& cvVector);
152 static Eigen::Matrix<float, 3, 1> toVector3f(const cv::Mat& cvVector);
157 static Eigen::Matrix<double, 3, 1> toVector3d(const cv::Point3_<float>& scvPoint);
162 static Eigen::Matrix<double, 3, 3> toMatrix3d(const cv::Mat& cvMat3);
167 static Eigen::Matrix<double, 4, 4> toMatrix4d(const cv::Mat& cvMat4);
172 static Eigen::Matrix<float, 3, 3> toMatrix3f(const cv::Mat& cvMat3);
177 static Eigen::Matrix<float, 4, 4> toMatrix4f(const cv::Mat& cvMat4);
178
183 static bool isRotationMatrix(const cv::Mat& R);
188 static Buffer<float> toEuler(const cv::Mat& R);
189
194 static Sophus::SE3<g_type, 0> toSophus(const cv::Mat& T);
199 static Sophus::Sim3<g_type, 0> toSophus(const Sim3& S);
200 };
201
202}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Utility class for converting between OpenCV, Eigen, Sophus, and NDEVR matrix types.
Definition Converter.h:30
static cv::Mat toCvMat(const Eigen::Matrix< double, 3, 3 > &m)
Converts a 3x3 double Eigen matrix to OpenCV Mat.
static SE3Quat toSE3Quat(const cv::Mat &cvT)
Converts an OpenCV 4x4 transform to SE3Quat.
static Eigen::Matrix< double, 4, 4 > toMatrix4d(const cv::Mat &cvMat4)
Converts an OpenCV 4x4 Mat to a double Eigen matrix.
static Eigen::Matrix< float, 4, 4 > toMatrix4f(const cv::Mat &cvMat4)
Converts an OpenCV 4x4 Mat to a float Eigen matrix.
static Eigen::Matrix< float, 3, 3 > toMatrix3f(const cv::Mat &cvMat3)
Converts an OpenCV 3x3 Mat to a float Eigen matrix.
static Matrix< fltp04 > ToNDVMat(const Eigen::Matrix< float, 4, 4 > &m)
Converts a 4x4 float Eigen matrix to an NDEVR Matrix.
Definition Converter.h:105
static cv::Mat toCvMat(const Eigen::Matrix< float, 3, 3 > &m)
Converts a 3x3 float Eigen matrix to OpenCV Mat.
static Buffer< cv::Mat, BufferAllocator< cv::Mat, 64, false > > toDescriptorVector(const cv::Mat &Descriptors)
Converts a descriptor matrix into a buffer of individual row descriptors.
static cv::Mat toCvMat(const SE3Quat &SE3)
Converts an SE3Quat to an OpenCV 4x4 Mat.
static cv::Mat toCvMat(const Eigen::Matrix< double, 4, 4 > &m)
Converts a 4x4 double Eigen matrix to OpenCV Mat.
static Sophus::SE3< g_type, 0 > toSophus(const cv::Mat &T)
Converts an OpenCV 4x4 Mat to a Sophus SE3.
static Eigen::Matrix< float, 3, 1 > toVector3f(const cv::Mat &cvVector)
Converts an OpenCV Mat to a 3D float Eigen vector.
static cv::Mat toCvMat(const Eigen::Matrix< double, -1, -1 > &m)
Converts a dynamic-size double Eigen matrix to OpenCV Mat.
static cv::Mat toCvSE3(const Eigen::Matrix< double, 3, 3 > &R, const Eigen::Matrix< double, 3, 1 > &t)
Builds a 4x4 SE3 OpenCV Mat from a rotation and translation (double).
static cv::Mat toCvMat(const Sim3 &Sim3)
Converts a Sim3 to an OpenCV 4x4 Mat.
static Eigen::Matrix< double, 3, 1 > toVector3d(const cv::Mat &cvVector)
Converts an OpenCV Mat to a 3D double Eigen vector.
static cv::Mat toCvMat(const Eigen::Matrix< float, -1, -1 > &m)
Converts a dynamic-size float Eigen matrix to OpenCV Mat.
static Buffer< float > toEuler(const cv::Mat &R)
Converts a rotation matrix to Euler angles.
static Sophus::Sim3< g_type, 0 > toSophus(const Sim3 &S)
Converts an NDEVR Sim3 to a Sophus Sim3.
static cv::Mat toCvSE3(const Eigen::Matrix< fltp04, 3, 3 > &R, const Eigen::Matrix< fltp04, 3, 1 > &t)
Builds a 4x4 SE3 OpenCV Mat from a rotation and translation (float).
static SE3Quat toSE3Quat(const Sophus::SE3< float, 0 > &T)
Converts a Sophus SE3 to SE3Quat.
static cv::Mat toCvMat(const Eigen::Matrix< float, 3, 4 > &m)
Converts a 3x4 float Eigen matrix to OpenCV Mat.
static Eigen::Matrix< double, 3, 3 > toMatrix3d(const cv::Mat &cvMat3)
Converts an OpenCV 3x3 Mat to a double Eigen matrix.
static cv::Mat toCvMat(const Eigen::Matrix< float, 3, 1 > &m)
Converts a 3x1 float Eigen vector to OpenCV Mat.
static cv::Mat toCvMat(const Eigen::Matrix< float, 4, 4 > &m)
Converts a 4x4 float Eigen matrix to OpenCV Mat.
static bool isRotationMatrix(const cv::Mat &R)
Checks whether a given matrix is a valid rotation matrix.
static cv::Mat toCvMat(const Eigen::Matrix< double, 3, 1 > &m)
Converts a 3x1 double Eigen vector to OpenCV Mat.
static SE3Quat toSE3Quat(const Sim3 &gSim3)
Converts a Sim3 to SE3Quat (discards scale).
static cv::Mat tocvSkewMatrix(const cv::Mat &v)
Converts a 3-vector to a skew-symmetric matrix.
static Eigen::Matrix< double, 3, 1 > toVector3d(const cv::Point3_< float > &scvPoint)
Converts an OpenCV Point3f to a 3D double Eigen vector.
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
SE(3) rigid body transformation represented by a unit quaternion and translation vector.
Definition se3quat.h:42
The primary namespace for the NDEVR SDK.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408
Similarity transformation in 3D (rotation + translation + scale).
Definition sim3.h:13