6 #ifndef __MXARRAY_HPP__ 7 #define __MXARRAY_HPP__ 14 #include "opencv2/opencv.hpp" 21 static const mxClassID
type = mxUNKNOWN_CLASS;
28 static const mxClassID
type = mxINT8_CLASS;
35 static const mxClassID
type = mxUINT8_CLASS;
42 static const mxClassID
type = mxINT16_CLASS;
49 static const mxClassID
type = mxUINT16_CLASS;
56 static const mxClassID
type = mxINT32_CLASS;
63 static const mxClassID
type = mxUINT32_CLASS;
70 static const mxClassID
type = mxINT64_CLASS;
77 static const mxClassID
type = mxUINT64_CLASS;
84 static const mxClassID
type = mxSINGLE_CLASS;
91 static const mxClassID
type = mxDOUBLE_CLASS;
98 static const mxClassID
type = mxCHAR_CLASS;
105 static const mxClassID
type = mxLOGICAL_CLASS;
118 int MexErrorHandler(
int status,
const char *func_name,
const char *err_msg,
119 const char *file_name,
int line,
void *userdata);
148 explicit MxArray(
const double d);
153 explicit MxArray(
const bool b);
158 explicit MxArray(
const std::string& s);
183 explicit MxArray(
const cv::Mat& mat,
184 mxClassID classid = mxUNKNOWN_CLASS,
bool transpose =
true);
189 explicit MxArray(
const cv::SparseMat& mat);
194 explicit MxArray(
const cv::Moments& m);
199 explicit MxArray(
const cv::KeyPoint& p);
204 explicit MxArray(
const cv::DMatch& m);
209 explicit MxArray(
const cv::RotatedRect& r);
214 explicit MxArray(
const cv::TermCriteria& t);
231 template <
typename T>
explicit MxArray(
const std::vector<T>& v)
243 template <
typename T>
explicit MxArray(
const cv::Point_<T>& p);
248 template <
typename T>
explicit MxArray(
const cv::Point3_<T>& p);
253 template <
typename T>
explicit MxArray(
const cv::Size_<T>& s);
258 template <
typename T>
explicit MxArray(
const cv::Rect_<T>& r);
263 template <
typename T>
explicit MxArray(
const cv::Scalar_<T>& s);
268 template <
typename T,
int cn>
explicit MxArray(
const cv::Vec<T,cn>& vec);
274 template <
typename T,
int m,
int n>
explicit MxArray(
const cv::Matx<T,m,n>& mat);
290 static inline MxArray
Cell(mwSize m = 1, mwSize n = 1)
292 mxArray *pm = mxCreateCellMatrix(m,n);
294 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
312 static inline MxArray
Struct(
const char** fields = NULL,
313 int nfields = 0, mwSize m = 1, mwSize n = 1)
315 mxArray *pm = mxCreateStructMatrix(m, n, nfields, fields);
317 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
323 MxArray clone()
const;
329 void destroy() { mxDestroyArray(const_cast<mxArray*>(p_)); }
333 operator const mxArray*()
const {
return p_; };
339 operator mxArray*()
const {
return const_cast<mxArray*
>(p_); };
347 double toDouble()
const;
351 float toFloat()
const;
359 std::string toString()
const;
386 cv::Mat toMat(
int depth = CV_USRTYPE1,
bool transpose =
true)
const;
413 cv::MatND toMatND(
int depth = CV_USRTYPE1,
bool transpose =
true)
const;
421 cv::SparseMat toSparseMat(
int depth = CV_USRTYPE1)
const;
426 cv::Moments toMoments(mwIndex index = 0)
const;
431 cv::KeyPoint toKeyPoint(mwIndex index = 0)
const;
436 cv::DMatch toDMatch(mwIndex index = 0)
const;
440 cv::Range toRange()
const;
445 cv::RotatedRect toRotatedRect(mwIndex index = 0)
const;
450 cv::TermCriteria toTermCriteria(mwIndex index = 0)
const;
454 template <
typename T> cv::Point_<T> toPoint_()
const;
458 template <
typename T> cv::Point3_<T> toPoint3_()
const;
462 template <
typename T> cv::Size_<T> toSize_()
const;
466 template <
typename T> cv::Rect_<T> toRect_()
const;
470 template <
typename T> cv::Scalar_<T> toScalar_()
const;
474 template <
typename T,
int cn> cv::Vec<T,cn> toVec()
const;
478 template <
typename T,
int m,
int n> cv::Matx<T,m,n> toMatx()
const;
490 template <
typename T> std::vector<T> toVector()
const;
506 template <
typename T>
507 std::vector<T> toVector(std::const_mem_fun_ref_t<T, MxArray> f)
const;
511 inline cv::Point
toPoint()
const {
return toPoint_<int>(); }
515 inline cv::Point2f
toPoint2f()
const {
return toPoint_<float>(); }
519 inline cv::Point3f
toPoint3f()
const {
return toPoint3_<float>(); }
523 inline cv::Size
toSize()
const {
return toSize_<int>(); }
527 inline cv::Rect
toRect()
const {
return toRect_<int>(); }
531 inline cv::Scalar
toScalar()
const {
return toScalar_<double>(); }
535 inline mxClassID
classID()
const {
return mxGetClassID(p_); }
541 return std::string(mxGetClassName(p_));
546 inline mwSize
numel()
const {
return mxGetNumberOfElements(p_); }
550 inline mwSize
ndims()
const {
return mxGetNumberOfDimensions(p_); }
554 inline const mwSize*
dims()
const {
return mxGetDimensions(p_); }
558 inline mwSize
rows()
const {
return mxGetM(p_); }
565 inline mwSize
cols()
const {
return mxGetN(p_); }
569 inline int nfields()
const {
return mxGetNumberOfFields(p_); }
574 std::string fieldname(
int fieldnumber)
const;
578 std::vector<std::string> fieldnames()
const;
583 inline mwSize
nzmax()
const {
return mxGetNzmax(p_); }
592 mwIndex subs(mwIndex i, mwIndex j = 0)
const;
601 mwIndex subs(
const std::vector<mwIndex>& si)
const;
606 inline bool isNull()
const {
return (p_ == NULL); }
610 inline bool isCell()
const {
return mxIsCell(p_); }
614 inline bool isChar()
const {
return mxIsChar(p_); }
626 return mxIsClass(p_, s.c_str());
632 inline bool isComplex()
const {
return mxIsComplex(p_); }
637 inline bool isDouble()
const {
return mxIsDouble(p_); }
643 inline bool isEmpty()
const {
return mxIsEmpty(p_); }
648 static inline bool isFinite(
double d) {
return mxIsFinite(d); }
658 static inline bool isInf(
double d) {
return mxIsInf(d); }
662 inline bool isInt8()
const {
return mxIsInt8(p_); }
666 inline bool isInt16()
const {
return mxIsInt16(p_); }
670 inline bool isInt32()
const {
return mxIsInt32(p_); }
674 inline bool isInt64()
const {
return mxIsInt64(p_); }
678 inline bool isLogical()
const {
return mxIsLogical(p_); }
690 return mxIsLogicalScalarTrue(p_);
695 inline bool isNumeric()
const {
return mxIsNumeric(p_); }
700 inline bool isSingle()
const {
return mxIsSingle(p_); }
704 inline bool isSparse()
const {
return mxIsSparse(p_); }
708 inline bool isStruct()
const {
return mxIsStruct(p_); }
712 inline bool isUint8()
const {
return mxIsUint8(p_); }
716 inline bool isUint16()
const {
return mxIsUint16(p_); }
720 inline bool isUint32()
const {
return mxIsUint32(p_); }
724 inline bool isUint64()
const {
return mxIsUint64(p_); }
731 return (isUint8() || isInt8() || isUint16() || isInt16() ||
732 isUint32() || isInt32() || isUint64() || isInt64());
738 inline bool isFloat()
const {
return (isDouble() || isSingle()); }
743 inline bool isField(
const std::string& fieldName)
const 745 return isStruct() && mxGetFieldNumber(p_, fieldName.c_str()) != -1;
766 template <
typename T> T at(mwIndex index)
const;
780 template <
typename T> T at(mwIndex i, mwIndex j)
const;
793 template <
typename T> T at(
const std::vector<mwIndex>& si)
const;
810 MxArray at(
const std::string& fieldName, mwIndex index = 0)
const;
829 template <
typename T>
void set(mwIndex index,
const T& value);
840 template <
typename T>
void set(mwIndex i, mwIndex j,
const T& value);
850 template <
typename T>
void set(
const std::vector<mwIndex>& si,
871 template <
typename T>
void set(
const std::string& fieldName,
872 const T& value, mwIndex index = 0);
877 static inline bool isNaN(
double d) {
return mxIsNaN(d); }
881 static inline double Inf() {
return mxGetInf(); }
885 static inline double NaN() {
return mxGetNaN(); }
893 static inline double Eps() {
return mxGetEps(); }
905 template <
typename T>
void fromVector(
const std::vector<T>& v);
926 template <
typename T,
typename U>
942 operator std::map<T,U>()
const {
return m_; }
944 const U& operator[] (
const T& key)
const 946 typename std::map<T,U>::const_iterator it = m_.find(key);
948 mexErrMsgIdAndTxt(
"mexopencv:error",
"ConstMap: Value not found");
956 template <
typename T>
957 void MxArray::fromVector(
const std::vector<T>& v)
960 p_ = mxCreateCellMatrix(1, v.size());
962 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
963 for (mwIndex i = 0; i < v.size(); ++i)
964 mxSetCell(const_cast<mxArray*>(p_), i,
MxArray(v[i]));
968 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
969 std::copy(v.begin(), v.end(),
reinterpret_cast<T*
>(mxGetData(p_)));
973 template <
typename T>
975 : p_(mxCreateNumericMatrix(1, 2, mxDOUBLE_CLASS, mxREAL))
978 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
979 double *x = mxGetPr(p_);
980 x[0] =
static_cast<double>(p.x);
981 x[1] =
static_cast<double>(p.y);
984 template <
typename T>
986 : p_(mxCreateNumericMatrix(1, 3, mxDOUBLE_CLASS, mxREAL))
989 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
990 double *x = mxGetPr(p_);
991 x[0] =
static_cast<double>(p.x);
992 x[1] =
static_cast<double>(p.y);
993 x[2] =
static_cast<double>(p.z);
996 template <
typename T>
998 : p_(mxCreateNumericMatrix(1, 2, mxDOUBLE_CLASS, mxREAL))
1001 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
1002 double *x = mxGetPr(p_);
1003 x[0] =
static_cast<double>(s.width);
1004 x[1] =
static_cast<double>(s.height);
1007 template <
typename T>
1009 : p_(mxCreateNumericMatrix(1, 4, mxDOUBLE_CLASS, mxREAL))
1012 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
1013 double *x = mxGetPr(p_);
1014 x[0] =
static_cast<double>(r.x);
1015 x[1] =
static_cast<double>(r.y);
1016 x[2] =
static_cast<double>(r.width);
1017 x[3] =
static_cast<double>(r.height);
1020 template <
typename T>
1022 : p_(mxCreateNumericMatrix(1, 4, mxDOUBLE_CLASS, mxREAL))
1025 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
1026 double *x = mxGetPr(p_);
1027 x[0] =
static_cast<double>(s[0]);
1028 x[1] =
static_cast<double>(s[1]);
1029 x[2] =
static_cast<double>(s[2]);
1030 x[3] =
static_cast<double>(s[3]);
1033 template <
typename T,
int cn>
1035 : p_(mxCreateNumericMatrix(1, cn, mxDOUBLE_CLASS, mxREAL))
1038 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
1045 std::copy(vec.val, vec.val + cn, mxGetPr(p_));
1048 template <
typename T,
int m,
int n>
1050 : p_(mxCreateNumericMatrix(m, n, mxDOUBLE_CLASS, mxREAL))
1053 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
1062 const cv::Matx<T, n, m> mat_t = mat.t();
1063 std::copy(mat_t.val, mat_t.val + m*n, mxGetPr(p_));
1066 template <
typename T>
1070 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a cv::Point");
1071 return cv::Point_<T>(at<T>(0), at<T>(1));
1074 template <
typename T>
1078 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a cv::Point3");
1079 return cv::Point3_<T>(at<T>(0), at<T>(1), at<T>(2));
1082 template <
typename T>
1086 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a cv::Size");
1087 return cv::Size_<T>(at<T>(0), at<T>(1));
1090 template <
typename T>
1094 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a cv::Rect");
1095 return cv::Rect_<T>(at<T>(0), at<T>(1), at<T>(2), at<T>(3));
1098 template <
typename T>
1101 const mwSize n =
numel();
1103 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a cv::Scalar");
1105 case 1:
return cv::Scalar_<T>(at<T>(0));
1106 case 2:
return cv::Scalar_<T>(at<T>(0), at<T>(1));
1107 case 3:
return cv::Scalar_<T>(at<T>(0), at<T>(1), at<T>(2));
1108 case 4:
return cv::Scalar_<T>(at<T>(0), at<T>(1), at<T>(2), at<T>(3));
1109 default:
return cv::Scalar_<T>();
1113 template <
typename T,
int cn>
1117 mexErrMsgIdAndTxt(
"mexopencv:error",
1118 "MxArray is not a cv::Vec%d", cn);
1125 for (mwIndex i = 0; i < cn; i++)
1130 template <
typename T,
int m,
int n>
1134 mexErrMsgIdAndTxt(
"mexopencv:error",
1135 "MxArray is not a cv::Matx%d%d", m, n);
1142 cv::Matx<T,m,n> mat;
1143 for (mwIndex j = 0; j<n; j++)
1144 for (mwIndex i = 0; i<m; i++)
1146 mat(i,j) = at<T>(i,j);
1150 template <
typename T>
1153 const mwSize n =
numel();
1163 case mxDOUBLE_CLASS: {
1164 const double *data = mxGetPr(p_);
1166 vt.assign(data, data + n);
1169 case mxSINGLE_CLASS: {
1170 const float *data =
reinterpret_cast<float*
>(mxGetData(p_));
1171 vt.assign(data, data + n);
1174 case mxUINT8_CLASS: {
1175 const uint8_t *data =
reinterpret_cast<uint8_t*
>(mxGetData(p_));
1176 vt.assign(data, data + n);
1179 case mxINT8_CLASS: {
1180 const int8_t *data =
reinterpret_cast<int8_t*
>(mxGetData(p_));
1181 vt.assign(data, data + n);
1184 case mxUINT16_CLASS: {
1185 const uint16_t *data =
reinterpret_cast<uint16_t*
>(mxGetData(p_));
1186 vt.assign(data, data + n);
1189 case mxINT16_CLASS: {
1190 const int16_t *data =
reinterpret_cast<int16_t*
>(mxGetData(p_));
1191 vt.assign(data, data + n);
1194 case mxUINT32_CLASS: {
1195 const uint32_t *data =
reinterpret_cast<uint32_t*
>(mxGetData(p_));
1196 vt.assign(data, data + n);
1199 case mxINT32_CLASS: {
1200 const int32_t *data =
reinterpret_cast<int32_t*
>(mxGetData(p_));
1201 vt.assign(data, data + n);
1204 case mxUINT64_CLASS: {
1205 const uint64_t *data =
reinterpret_cast<uint64_t*
>(mxGetData(p_));
1206 vt.assign(data, data + n);
1209 case mxINT64_CLASS: {
1210 const int64_t *data =
reinterpret_cast<int64_t*
>(mxGetData(p_));
1211 vt.assign(data, data + n);
1214 case mxCHAR_CLASS: {
1215 const mxChar *data = mxGetChars(p_);
1216 vt.assign(data, data + n);
1219 case mxLOGICAL_CLASS: {
1220 const mxLogical *data = mxGetLogicals(p_);
1221 vt.assign(data, data + n);
1229 for (mwIndex i = 0; i < n; ++i)
1231 vt.push_back(
MxArray(mxGetCell(p_, i)).at<T>(0));
1234 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a std::vector");
1238 template <
typename T>
1241 const std::vector<MxArray> v(toVector<MxArray>());
1243 vt.reserve(v.size());
1244 for (std::vector<MxArray>::const_iterator it=v.begin(); it!=v.end(); ++it)
1245 vt.push_back(f(*it));
1249 template <
typename T>
1253 mexErrMsgIdAndTxt(
"mexopencv:error",
"Null pointer error");
1255 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not primitive");
1256 if (
numel() <= index)
1257 mexErrMsgIdAndTxt(
"mexopencv:error",
"Index out of range");
1260 return static_cast<T
>(*(mxGetChars(p_) + index));
1261 case mxDOUBLE_CLASS:
1262 return static_cast<T
>(*(mxGetPr(p_) + index));
1264 return static_cast<T
>(
1265 *(
reinterpret_cast<int8_t*
>(mxGetData(p_)) + index));
1267 return static_cast<T
>(
1268 *(
reinterpret_cast<uint8_t*
>(mxGetData(p_)) + index));
1270 return static_cast<T
>(
1271 *(
reinterpret_cast<int16_t*
>(mxGetData(p_)) + index));
1272 case mxUINT16_CLASS:
1273 return static_cast<T
>(
1274 *(
reinterpret_cast<uint16_t*
>(mxGetData(p_)) + index));
1276 return static_cast<T
>(
1277 *(
reinterpret_cast<int32_t*
>(mxGetData(p_)) + index));
1278 case mxUINT32_CLASS:
1279 return static_cast<T
>(
1280 *(
reinterpret_cast<uint32_t*
>(mxGetData(p_)) + index));
1282 return static_cast<T
>(
1283 *(
reinterpret_cast<int64_t*
>(mxGetData(p_)) + index));
1284 case mxUINT64_CLASS:
1285 return static_cast<T
>(
1286 *(
reinterpret_cast<uint64_t*
>(mxGetData(p_)) + index));
1287 case mxSINGLE_CLASS:
1288 return static_cast<T
>(
1289 *(
reinterpret_cast<float*
>(mxGetData(p_)) + index));
1290 case mxLOGICAL_CLASS:
1291 return static_cast<T
>(*(mxGetLogicals(p_) + index));
1293 return static_cast<T
>(0);
1297 template <
typename T>
1300 return at<T>(
subs(i,j));
1303 template <
typename T>
1306 return at<T>(
subs(si));
1309 template <
typename T>
1313 mexErrMsgIdAndTxt(
"mexopencv:error",
"Null pointer error");
1315 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not primitive");
1316 if (
numel() <= index)
1317 mexErrMsgIdAndTxt(
"mexopencv:error",
"Index out of range");
1320 *(mxGetChars(p_) + index) = static_cast<mxChar>(value);
1322 case mxDOUBLE_CLASS:
1323 *(mxGetPr(p_) + index) = static_cast<double>(value);
1326 *(
reinterpret_cast<int8_t*
>(mxGetData(p_)) + index) =
1327 static_cast<int8_t
>(value);
1330 *(
reinterpret_cast<uint8_t*
>(mxGetData(p_)) + index) =
1331 static_cast<uint8_t
>(value);
1334 *(
reinterpret_cast<int16_t*
>(mxGetData(p_)) + index) =
1335 static_cast<int16_t
>(value);
1337 case mxUINT16_CLASS:
1338 *(
reinterpret_cast<uint16_t*
>(mxGetData(p_)) + index) =
1339 static_cast<uint16_t
>(value);
1342 *(
reinterpret_cast<int32_t*
>(mxGetData(p_)) + index) =
1343 static_cast<int32_t
>(value);
1345 case mxUINT32_CLASS:
1346 *(
reinterpret_cast<uint32_t*
>(mxGetData(p_)) + index) =
1347 static_cast<uint32_t
>(value);
1350 *(
reinterpret_cast<int64_t*
>(mxGetData(p_)) + index) =
1351 static_cast<int64_t
>(value);
1353 case mxUINT64_CLASS:
1354 *(
reinterpret_cast<uint64_t*
>(mxGetData(p_)) + index) =
1355 static_cast<uint64_t
>(value);
1357 case mxSINGLE_CLASS:
1358 *(
reinterpret_cast<float*
>(mxGetData(p_)) + index) =
1359 static_cast<float>(value);
1361 case mxLOGICAL_CLASS:
1362 *(mxGetLogicals(p_) + index) = static_cast<mxLogical>(value);
1369 template <
typename T>
1372 set<T>(
subs(i,j), value);
1375 template <
typename T>
1378 set<T>(
subs(si), value);
1381 template <
typename T>
1382 void MxArray::set(
const std::string& fieldName,
const T& value, mwIndex index)
1385 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not struct");
1386 if (
numel() <= index)
1387 mexErrMsgIdAndTxt(
"mexopencv:error",
"Index out of range");
1389 if (mxAddField(const_cast<mxArray*>(p_), fieldName.c_str()) < 0)
1390 mexErrMsgIdAndTxt(
"mexopencv:error",
1391 "Failed to create a field '%s'", fieldName.c_str());
1393 mxSetField(const_cast<mxArray*>(p_), index, fieldName.c_str(),
1394 static_cast<mxArray*
>(
MxArray(value)));
1402 void MxArray::fromVector(
const std::vector<char>& v);
1409 void MxArray::fromVector(
const std::vector<bool>& v);
1852 #endif // __MXARRAY_HPP__ bool isInt32() const
Determine whether array represents data as signed 32-bit integers.
MxArray(const std::vector< T > &v)
MxArray constructor from vector<T>.
bool isSparse() const
Determine whether input is sparse array.
static double Inf()
Value of infinity.
void destroy()
Deallocate memory occupied by mxArray.
cv::Point_< T > toPoint_() const
Convert MxArray to Point_<T>.
bool isUint64() const
Determine whether array represents data as unsigned 64-bit integers.
MxArray(const MxArray &arr)
Copy constructor.
mwSize nzmax() const
Number of elements in IR, PR, and PI arrays.
bool isSingle() const
Determine whether array represents data as single-precision, floating-point numbers.
static const mxClassID type
maps general template parameter to unkown MATLAB type.
bool isStruct() const
Determine whether input is structure array.
bool isEmpty() const
Determine whether array is empty.
bool isInteger() const
Determine whether array represents data as integer types (8-bit, 16-bit, 32-bit or 64-bit...
bool isFloat() const
Determine whether array represents data as floating-point numbers, both single and double precision...
cv::Point2f toPoint2f() const
Alias to toPoint_<float>.
cv::Size toSize() const
Alias to toSize_<int>.
bool isInt64() const
Determine whether array represents data as signed 64-bit integers.
bool isUint32() const
Determine whether array represents data as unsigned 32-bit integers.
mwIndex subs(mwIndex i, mwIndex j=0) const
Offset from first element to desired element.
cv::Size_< T > toSize_() const
Convert MxArray to Size_<T>.
static double NaN()
Value of NaN (Not-a-Number).
bool isFromGlobalWS() const
Determine whether array was copied from MATLAB global workspace.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
bool isChar() const
Determine whether input is string array.
const std::string className() const
Class name of mxArray.
bool isClass(std::string s) const
Determine whether array is member of specified class.
mxClassID classID() const
Class ID of mxArray.
bool isUint16() const
Determine whether array represents data as unsigned 16-bit integers.
static bool isFinite(double d)
Determine whether input is finite.
virtual ~MxArray()
Destructor.
cv::Scalar_< T > toScalar_() const
Convert MxArray to Scalar_<T>.
int MexErrorHandler(int status, const char *func_name, const char *err_msg, const char *file_name, int line, void *userdata)
Cutom error callback to be invoked by cv::error(), CV_Assert, etc...
cv::Point toPoint() const
Alias to toPoint_<int>.
std::vector< T > toVector() const
Convert MxArray to std::vector<T> of primitive types.
cv::Vec< T, cn > toVec() const
Convert MxArray to Vec<T,cn>.
bool isComplex() const
Determine whether data is complex.
mxArray object wrapper for data conversion and manipulation.
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
cv::Point3f toPoint3f() const
Alias to toPoint3_<float>.
bool isInt8() const
Determine whether array represents data as signed 8-bit integers.
cv::Point3_< T > toPoint3_() const
Convert MxArray to Point3_<T>.
static MxArray Cell(mwSize m=1, mwSize n=1)
Create a new cell array.
bool isNull() const
Determine whether the array is initialized or not.
bool isField(const std::string &fieldName) const
Determine whether a struct array has a specified field.
bool isUint8() const
Determine whether array represents data as unsigned 8-bit integers.
ConstMap(const T &key, const U &val)
Constructor with a single key-value pair.
cv::Scalar toScalar() const
Alias to toScalar_<double>
cv::Matx< T, m, n > toMatx() const
Convert MxArray to Matx<T,m,n>.
bool isLogical() const
Determine whether array is of type mxLogical.
mwSize numel() const
Number of elements in an array.
int nfields() const
Number of fields in a struct array.
MxArray(const mxArray *arr)
MxArray constructor from mxArray*.
cv::Rect_< T > toRect_() const
Convert MxArray to Rect_<T>.
static bool isInf(double d)
Determine whether input is infinite.
mwSize ndims() const
Number of dimensions.
bool isLogicalScalarTrue() const
Determine whether scalar array of type mxLogical is true.
bool isDouble() const
Determine whether mxArray represents data as double-precision, floating-point numbers.
cv::Rect toRect() const
Alias to toRect_<int>.
T at(mwIndex index) const
Template for numeric array element accessor.
bool isLogicalScalar() const
Determine whether scalar array is of type mxLogical.
std::map wrapper with one-line initialization and lookup method.
const mwSize * dims() const
Array of each dimension.
static bool isNaN(double d)
Determine whether input is NaN (Not-a-Number).
bool isInt16() const
Determine whether array represents data as signed 16-bit integers.
static double Eps()
Value of EPS.
bool isNumeric() const
Determine whether array is numeric.
mwSize rows() const
Number of rows in an array.
mwSize cols() const
Number of columns in an array.
bool isCell() const
Determine whether input is cell array.