43 #ifndef __OPENCV_CORE_EIGEN_HPP__
44 #define __OPENCV_CORE_EIGEN_HPP__
51 #if defined _MSC_VER && _MSC_VER >= 1200
52 #pragma warning( disable: 4714 ) //__forceinline is not inlined
53 #pragma warning( disable: 4127 ) //conditional expression is constant
54 #pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data
60 template<
typename _Tp,
int _rows,
int _cols,
int _options,
int _maxRows,
int _maxCols>
61 void eigen2cv(
const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>&
src,
Mat&
dst )
63 if( !(src.Flags & Eigen::RowMajorBit) )
66 (
void*)src.data(), src.stride()*
sizeof(_Tp));
72 (
void*)src.data(), src.stride()*
sizeof(_Tp));
77 template<
typename _Tp,
int _rows,
int _cols,
int _options,
int _maxRows,
int _maxCols>
79 Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>&
dst )
81 CV_DbgAssert(src.
rows == _rows && src.
cols == _cols);
82 if( !(dst.Flags & Eigen::RowMajorBit) )
85 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
86 if( src.
type() == _dst.type() )
94 Mat(src.
t()).convertTo(_dst, _dst.type());
95 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
100 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
102 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
107 template<
typename _Tp,
int _rows,
int _cols,
int _options,
int _maxRows,
int _maxCols>
109 Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>&
dst )
111 if( !(dst.Flags & Eigen::RowMajorBit) )
114 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
116 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
121 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
123 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
127 template<
typename _Tp>
129 Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>&
dst )
132 if( !(dst.Flags & Eigen::RowMajorBit) )
135 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
136 if( src.
type() == _dst.type() )
144 Mat(src.
t()).convertTo(_dst, _dst.type());
145 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
150 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
152 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
157 template<
typename _Tp,
int _rows,
int _cols>
159 Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>&
dst )
161 dst.resize(_rows, _cols);
162 if( !(dst.Flags & Eigen::RowMajorBit) )
165 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
167 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
172 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
174 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
178 template<
typename _Tp>
180 Eigen::Matrix<_Tp, Eigen::Dynamic, 1>&
dst )
182 CV_Assert(src.
cols == 1);
183 dst.resize(src.
rows);
185 if( !(dst.Flags & Eigen::RowMajorBit) )
188 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
189 if( src.
type() == _dst.type() )
192 Mat(src.
t()).convertTo(_dst, _dst.type());
193 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
198 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
200 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
205 template<
typename _Tp,
int _rows>
207 Eigen::Matrix<_Tp, Eigen::Dynamic, 1>&
dst )
211 if( !(dst.Flags & Eigen::RowMajorBit) )
214 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
216 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
221 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
223 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
228 template<
typename _Tp>
230 Eigen::Matrix<_Tp, 1, Eigen::Dynamic>&
dst )
232 CV_Assert(src.
rows == 1);
233 dst.resize(src.
cols);
234 if( !(dst.Flags & Eigen::RowMajorBit) )
237 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
238 if( src.
type() == _dst.type() )
241 Mat(src.
t()).convertTo(_dst, _dst.type());
242 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
247 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
249 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
254 template<
typename _Tp,
int _cols>
256 Eigen::Matrix<_Tp, 1, Eigen::Dynamic>&
dst )
259 if( !(dst.Flags & Eigen::RowMajorBit) )
262 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
264 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
269 dst.data(), (size_t)(dst.stride()*
sizeof(_Tp)));
271 CV_DbgAssert(_dst.data == (
uchar*)dst.data());
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions ...
Definition: core.hpp:1962
void cv2eigen(const Mat &src, Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &dst)
Definition: eigen.hpp:78
void copyTo(OutputArray m) const
copies the matrix content to "m".
void convertTo(OutputArray m, int rtype, double alpha=1, double beta=0) const
converts matrix to another datatype with optional scalng. See cvConvertScale.
GLuint src
Definition: core_c.h:1650
int cols
Definition: core.hpp:1962
int type() const
returns element type, similar to CV_MAT_TYPE(cvmat->type)
Definition: mat.hpp:399
CV_EXPORTS_W void transpose(InputArray src, OutputArray dst)
transposes the matrix
Informative template class for OpenCV "scalars".
Definition: core.hpp:1006
MatExpr t() const
matrix transposition by means of matrix expressions
The n-dimensional matrix class.
Definition: core.hpp:1688
unsigned char uchar
Definition: types_c.h:170
void eigen2cv(const Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &src, Mat &dst)
Definition: eigen.hpp:61
GLuint dst
Definition: calib3d.hpp:134