11 const char *cv_moments_fields[24] = {
12 "m00",
"m10",
"m01",
"m20",
"m11",
"m02",
"m30",
"m21",
"m12",
"m03",
13 "mu20",
"mu11",
"mu02",
"mu30",
"mu21",
"mu12",
"mu03",
14 "nu20",
"nu11",
"nu02",
"nu30",
"nu21",
"nu12",
"nu03"};
16 const char *cv_rotated_rect_fields[3] = {
"center",
"size",
"angle"};
18 const char *cv_term_criteria_fields[3] = {
"type",
"maxCount",
"epsilon"};
20 const char *cv_keypoint_fields[6] = {
"pt",
"size",
"angle",
"response",
21 "octave",
"class_id"};
23 const char *cv_dmatch_fields[4] = {
"queryIdx",
"trainIdx",
"imgIdx",
31 (mxDOUBLE_CLASS, CV_64F)
32 (mxSINGLE_CLASS, CV_32F)
34 (mxUINT8_CLASS, CV_8U)
35 (mxINT16_CLASS, CV_16S)
36 (mxUINT16_CLASS, CV_16U)
37 (mxINT32_CLASS, CV_32S)
38 (mxUINT32_CLASS, CV_32S)
39 (mxLOGICAL_CLASS, CV_8U);
46 (CV_64F, mxDOUBLE_CLASS)
47 (CV_32F, mxSINGLE_CLASS)
49 (CV_8U, mxUINT8_CLASS)
50 (CV_16S, mxINT16_CLASS)
51 (CV_16U, mxUINT16_CLASS)
52 (CV_32S, mxINT32_CLASS);
58 struct CompareSparseMatNode {
60 bool operator () (
const cv::SparseMat::Node* rhs,
61 const cv::SparseMat::Node* lhs)
const 64 if (rhs->idx[1] < lhs->idx[1])
66 if (rhs->idx[1] == lhs->idx[1] && rhs->idx[0] < lhs->idx[0])
74 (cv::TermCriteria::COUNT,
"Count")
75 (cv::TermCriteria::EPS,
"EPS")
76 (cv::TermCriteria::COUNT+cv::TermCriteria::EPS,
"Count+EPS");
80 (
"Count", cv::TermCriteria::COUNT)
81 (
"EPS", cv::TermCriteria::EPS)
82 (
"Count+EPS", cv::TermCriteria::COUNT+cv::TermCriteria::EPS);
87 const char *file_name,
int line,
void * )
89 mexErrMsgIdAndTxt(
"mexopencv:error",
94 " File : <a href=\"matlab:opentoline('%s',%d)\">%s</a>\n" 96 cvErrorStr(status), status, err_msg,
97 (func_name ? func_name :
"(unknown)"),
98 file_name, line, file_name, line);
110 : p_(mxCreateDoubleScalar(static_cast<double>(i)))
113 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
117 : p_(mxCreateDoubleScalar(d))
120 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
124 : p_(mxCreateLogicalScalar(b))
127 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
131 : p_(mxCreateString(s.c_str()))
134 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
150 classid = (classid == mxUNKNOWN_CLASS) ? ClassIDOf[mat.depth()] : classid;
152 p_ = mxCreateNumericMatrix(0, 0, classid, mxREAL);
154 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
159 if (input.dims == 2 && transpose)
162 const mwSize nchannels = input.channels();
163 const int* dims_ = input.size;
164 std::vector<mwSize> d(dims_, dims_ + input.dims);
165 d.push_back(nchannels);
166 std::swap(d[0], d[1]);
167 if (classid == mxLOGICAL_CLASS) {
169 cv::compare(input, 0, input, cv::CMP_NE);
170 input.setTo(1, input);
171 p_ = mxCreateLogicalArray(d.size(), &d[0]);
174 p_ = mxCreateNumericArray(d.size(), &d[0], classid, mxREAL);
176 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
178 std::vector<cv::Mat> channels;
179 channels.reserve(nchannels);
180 cv::split(input, channels);
183 std::vector<mwSize> si(d.size(), 0);
184 const int type = CV_MAKETYPE(DepthOf[classid], 1);
185 for (mwIndex i = 0; i < nchannels; ++i) {
186 si[si.size() - 1] = i;
187 void *ptr =
reinterpret_cast<void*
>(
188 reinterpret_cast<size_t>(mxGetData(p_)) +
189 mxGetElementSize(p_) *
subs(si));
190 cv::Mat m(input.dims, dims_, type, ptr);
191 channels[i].convertTo(m, type);
199 classid = (classid == mxUNKNOWN_CLASS) ? ClassIDOf[mat.depth()] : classid;
204 p_ = mxCreateNumericMatrix(0, 0, classid, mxREAL);
206 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
211 const mwSize cn = mat.channels();
212 const mwSize len = mat.total() * cn;
213 std::vector<mwSize> sz(mat.size.p, mat.size.p + mat.dims);
216 std::reverse(sz.begin(), sz.end());
217 if (classid == mxLOGICAL_CLASS)
218 p_ = mxCreateLogicalArray(sz.size(), &sz[0]);
220 p_ = mxCreateNumericArray(sz.size(), &sz[0], classid, mxREAL);
222 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
228 const int type = CV_MAKETYPE(DepthOf[classid], 1);
229 cv::Mat m(len, 1, type, mxGetData(p_));
232 const cv::Mat mat0(len, 1, mat.depth(), mat.data);
233 if (classid == mxLOGICAL_CLASS) {
235 cv::compare(mat0, 0, m, cv::CMP_NE);
239 mat0.convertTo(m, type);
246 std::vector<double> order;
247 order.reserve(sz.size());
248 for (
int i=sz.size(); i>0; i--)
252 mxArray *lhs, *rhs[2];
253 rhs[0] =
const_cast<mxArray*
>(p_);
256 if (mexCallMATLAB(1, &lhs, 2, rhs,
"permute") != 0)
257 mexErrMsgIdAndTxt(
"mexopencv:error",
"Error calling permute");
259 mxDestroyArray(rhs[0]);
260 mxDestroyArray(rhs[1]);
268 if (mat.dims() != 2 || mat.channels() != 1)
269 mexErrMsgIdAndTxt(
"mexopencv:error",
270 "Not a 2D 1-channel sparse matrix");
282 const mwSize m = mat.size(0), n = mat.size(1), nnz = mat.nzcount();
283 p_ = mxCreateSparse(m, n, nnz, mxREAL);
285 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
288 mwIndex *ir = mxGetIr(p_);
289 mwIndex *jc = mxGetJc(p_);
290 double *pr = mxGetPr(p_);
291 if (!ir || !jc || !pr)
292 mexErrMsgIdAndTxt(
"mexopencv:error",
"Null pointer error");
296 std::vector<const cv::SparseMat::Node*> nodes;
298 for (cv::SparseMat::const_iterator it = mat.begin(); it != mat.end(); ++it)
299 nodes.push_back(it.node());
301 std::sort(nodes.begin(), nodes.end(), CompareSparseMatNode());
305 for (mwIndex i = 0; i < nodes.size(); ++i) {
306 const mwIndex row = nodes[i]->idx[0], col = nodes[i]->idx[1];
310 switch (mat.depth()) {
312 pr[i] =
static_cast<double>(mat.value<uchar>(nodes[i]));
315 pr[i] =
static_cast<double>(mat.value<schar>(nodes[i]));
318 pr[i] =
static_cast<double>(mat.value<ushort>(nodes[i]));
321 pr[i] =
static_cast<double>(mat.value<
short>(nodes[i]));
324 pr[i] =
static_cast<double>(mat.value<
int>(nodes[i]));
327 pr[i] =
static_cast<double>(mat.value<
float>(nodes[i]));
330 pr[i] = mat.value<
double>(nodes[i]);
337 for (mwIndex i = 1; i < n+1; ++i) {
345 : p_(mxCreateStructMatrix(1, 1, 24, cv_moments_fields))
348 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
376 : p_(mxCreateStructMatrix(1, 1, 6, cv_keypoint_fields))
379 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
382 set(
"angle", p.angle);
383 set(
"response", p.response);
384 set(
"octave", p.octave);
385 set(
"class_id", p.class_id);
389 void MxArray::fromVector(
const std::vector<char>& v)
391 const mwSize size[] = {1, v.size()};
392 p_ = mxCreateCharArray(2, size);
394 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
395 std::copy(v.begin(), v.end(), mxGetChars(p_));
399 void MxArray::fromVector(
const std::vector<bool>& v)
401 p_ = mxCreateLogicalMatrix(1, v.size());
403 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
404 std::copy(v.begin(), v.end(), mxGetLogicals(p_));
409 : p_(mxCreateStructMatrix(1, v.size(), 6, cv_keypoint_fields))
412 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
413 for (mwIndex i = 0; i < v.size(); ++i) {
414 set(
"pt", v[i].pt, i);
415 set(
"size", v[i].size, i);
416 set(
"angle", v[i].angle, i);
417 set(
"response", v[i].response, i);
418 set(
"octave", v[i].octave, i);
419 set(
"class_id", v[i].class_id, i);
424 : p_(mxCreateStructMatrix(1, 1, 4, cv_keypoint_fields))
427 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
428 set(
"queryIdx", m.queryIdx);
429 set(
"trainIdx", m.trainIdx);
430 set(
"imgIdx", m.imgIdx);
431 set(
"distance", m.distance);
436 : p_(mxCreateStructMatrix(1, v.size(), 4, cv_dmatch_fields))
439 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
440 for (mwIndex i = 0; i < v.size(); ++i) {
441 set(
"queryIdx", v[i].queryIdx, i);
442 set(
"trainIdx", v[i].trainIdx, i);
443 set(
"imgIdx", v[i].imgIdx, i);
444 set(
"distance", v[i].distance, i);
449 : p_(mxCreateStructMatrix(1, 1, 3, cv_rotated_rect_fields))
452 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
453 set(
"center", r.center);
455 set(
"angle", r.angle);
460 : p_(mxCreateStructMatrix(1, v.size(), 3, cv_rotated_rect_fields))
463 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
464 for (mwIndex i = 0; i < v.size(); ++i) {
465 set(
"center", v[i].center, i);
466 set(
"size", v[i].size, i);
467 set(
"angle", v[i].angle, i);
472 : p_(mxCreateStructMatrix(1, 1, 3, cv_term_criteria_fields))
475 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
476 set(
"type", InvTermCritType[t.type]);
477 set(
"maxCount", t.maxCount);
478 set(
"epsilon", t.epsilon);
483 mxArray *pm = mxDuplicateArray(p_);
485 mexErrMsgIdAndTxt(
"mexopencv:error",
"Allocation error");
492 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a scalar");
499 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a scalar");
500 return at<double>(0);
506 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a scalar");
513 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a scalar");
520 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray not of type char");
521 char *pc = mxArrayToString(p_);
523 mexErrMsgIdAndTxt(
"mexopencv:error",
"Null pointer error");
539 cv::Mat matnd(
toMatND(depth, transpose));
540 CV_DbgAssert(matnd.isContinuous() && matnd.dims ==
ndims() && matnd.channels() == 1);
541 std::vector<int> d(matnd.size.p, matnd.size.p + matnd.dims);
542 const int cn = d.back();
543 const int type = CV_MAKETYPE(matnd.depth(), cn);
544 CV_Assert(cn <= CV_CN_MAX);
545 return matnd.reshape(cn, d.size()-1, &d[0]);
552 const mwSize
ndims = (d.size()>2) ? d.size()-1 : d.size();
553 const mwSize nchannels = (d.size()>2) ? d.back() : 1;
554 depth = (depth == CV_USRTYPE1) ? DepthOf[
classID()] : depth;
555 std::swap(d[0], d[1]);
556 cv::Mat mat(ndims, &d[0], CV_MAKETYPE(depth, nchannels));
559 std::vector<cv::Mat> channels(nchannels);
560 std::vector<mwSize> si(d.size(), 0);
561 const int type = CV_MAKETYPE(DepthOf[
classID()], 1);
562 for (mwIndex i = 0; i<nchannels; ++i) {
563 si[si.size() - 1] = i;
564 void *pd =
reinterpret_cast<void*
>(
565 reinterpret_cast<size_t>(mxGetData(p_)) +
566 mxGetElementSize(p_)*
subs(si));
567 const cv::Mat m(ndims, &d[0], type, pd);
569 m.convertTo(channels[i], CV_MAKETYPE(depth, 1));
573 cv::transpose(channels[i], channels[i]);
576 cv::merge(channels, mat);
586 std::swap(d[0], d[1]);
587 depth = (depth == CV_USRTYPE1) ? DepthOf[
classID()] : depth;
588 cv::MatND mat(d.size(), &d[0], CV_MAKETYPE(depth, 1));
590 const int type = CV_MAKETYPE(DepthOf[
classID()], 1);
591 const cv::MatND m(d.size(), &d[0], type, mxGetData(p_));
593 m.convertTo(mat, CV_MAKETYPE(depth, 1));
595 if (mat.dims==2 && transpose)
596 cv::transpose(mat, mat);
604 CV_Assert(
ndims() <= CV_MAX_DIM);
609 std::vector<double> order;
610 order.reserve(
ndims());
611 for (
int i=
ndims(); i>0; i--)
615 mxArray *lhs, *rhs[2];
616 rhs[0] =
const_cast<mxArray*
>(p_);
619 if (mexCallMATLAB(1, &lhs, 2, rhs,
"permute") != 0)
620 mexErrMsgIdAndTxt(
"mexopencv:error",
"Error calling permute");
621 mxDestroyArray(rhs[1]);
622 CV_DbgAssert(lhs!=NULL && mxGetClassID(lhs)==
classID() &&
623 mxGetNumberOfElements(lhs)==
numel());
628 depth = (depth == CV_USRTYPE1) ? DepthOf[
classID()] : depth;
629 cv::MatND mat(d.size(), &d[0], CV_MAKETYPE(depth, 1));
634 const int type = CV_MAKETYPE(DepthOf[
classID()], 1);
635 const cv::MatND m(d.size(), &d[0], type, mxGetData(lhs));
638 m.convertTo(mat, CV_MAKETYPE(depth, 1));
651 mexErrMsgIdAndTxt(
"mexopencv:error",
652 "MxArray is not real 2D double sparse");
655 depth = (depth == CV_USRTYPE1) ? DepthOf[
classID()] : depth;
656 const mwSize m =
rows(), n =
cols();
657 const int dims[] = {
static_cast<int>(m), static_cast<int>(n)};
658 cv::SparseMat mat(2, dims, depth);
661 const mwIndex *ir = mxGetIr(p_);
662 const mwIndex *jc = mxGetJc(p_);
663 const double *pr = mxGetPr(p_);
664 if (!ir || !jc || !pr)
665 mexErrMsgIdAndTxt(
"mexopencv:error",
"Null pointer error");
668 for (mwIndex j = 0; j < n; ++j) {
670 const mwIndex start = jc[j], end = jc[j+1];
671 for (mwIndex i = start; i < end; ++i) {
674 switch (mat.depth()) {
676 mat.ref<uchar>(ir[i], j) = static_cast<uchar>(pr[i]);
679 mat.ref<schar>(ir[i], j) = static_cast<schar>(pr[i]);
682 mat.ref<ushort>(ir[i], j) = static_cast<ushort>(pr[i]);
685 mat.ref<
short>(ir[i], j) = static_cast<short>(pr[i]);
688 mat.ref<
int>(ir[i], j) = static_cast<int>(pr[i]);
691 mat.ref<
float>(ir[i], j) = static_cast<float>(pr[i]);
694 mat.ref<
double>(ir[i], j) = pr[i];
748 r = cv::Range(at<int>(0), at<int>(1));
750 r = cv::Range::all();
752 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid range value");
759 if (
isField(
"center")) rr.center =
at(
"center", index).toPoint_<
float>();
760 if (
isField(
"size")) rr.size =
at(
"size", index).toSize_<
float>();
761 if (
isField(
"angle")) rr.angle =
at(
"angle", index).toFloat();
768 return cv::TermCriteria(
770 at(
"maxCount", index).toInt(),
771 at(
"epsilon", index).toDouble()
778 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not struct");
779 const char *fname = mxGetFieldNameByNumber(p_, fieldnumber);
781 mexErrMsgIdAndTxt(
"mexopencv:error",
782 "Failed to get field name at %d\n", fieldnumber);
783 return std::string(fname);
789 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not a struct array");
791 std::vector<std::string> v;
793 for (mwIndex i = 0; i < n; ++i)
801 mexErrMsgIdAndTxt(
"mexopencv:error",
"Subscript out of range");
802 mwIndex si[] = {i, j};
803 return mxCalcSingleSubscript(p_, 2, si);
808 std::vector<mwIndex> v(si);
809 return mxCalcSingleSubscript(p_, si.size(), (!v.empty() ? &v[0] : NULL));
815 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not struct");
816 if (
numel() <= index)
817 mexErrMsgIdAndTxt(
"mexopencv:error",
"Index out of range");
818 const mxArray* pm = mxGetField(p_, index, fieldName.c_str());
820 mexErrMsgIdAndTxt(
"mexopencv:error",
821 "Field '%s' doesn't exist", fieldName.c_str());
829 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not cell");
830 if (
numel() <= index)
831 mexErrMsgIdAndTxt(
"mexopencv:error",
"Index out of range");
832 return MxArray(mxGetCell(p_, index));
839 mexErrMsgIdAndTxt(
"mexopencv:error",
"MxArray is not cell");
840 if (
numel() <= index)
841 mexErrMsgIdAndTxt(
"mexopencv:error",
"Index out of range");
842 mxSetCell(const_cast<mxArray*>(p_), index, static_cast<mxArray*>(value));
848 std::vector<MxArray> v;
850 const mwSize n =
numel();
852 for (mwIndex i = 0; i < n; ++i)
854 v.push_back(
MxArray(mxGetCell(p_, i)));
871 const std::vector<MxArray> v(toVector<MxArray>());
872 std::vector<cv::Mat> vm;
873 vm.reserve(v.size());
874 for (std::vector<MxArray>::const_iterator it = v.begin(); it != v.end(); ++it)
875 vm.push_back((*it).toMat());
883 std::vector<cv::Point> vp;
887 toMat(CV_32S).reshape(2, 0).copyTo(vp);
892 std::const_mem_fun_ref_t<cv::Point, MxArray>(
893 &MxArray::toPoint_<int>));
901 std::vector<cv::Point2f> vp;
905 toMat(CV_32F).reshape(2, 0).copyTo(vp);
910 std::const_mem_fun_ref_t<cv::Point2f, MxArray>(
911 &MxArray::toPoint_<float>));
919 std::vector<cv::Point2d> vp;
921 vp.push_back(toPoint_<double>());
923 toMat(CV_64F).reshape(2, 0).copyTo(vp);
928 std::const_mem_fun_ref_t<cv::Point2d, MxArray>(
929 &MxArray::toPoint_<double>));
937 std::vector<cv::Point3i> vp;
939 vp.push_back(toPoint3_<int>());
941 toMat(CV_32S).reshape(3, 0).copyTo(vp);
946 std::const_mem_fun_ref_t<cv::Point3i, MxArray>(
947 &MxArray::toPoint3_<int>));
955 std::vector<cv::Point3f> vp;
959 toMat(CV_32F).reshape(3, 0).copyTo(vp);
964 std::const_mem_fun_ref_t<cv::Point3f, MxArray>(
965 &MxArray::toPoint3_<float>));
973 std::vector<cv::Point3d> vp;
975 vp.push_back(toPoint3_<double>());
977 toMat(CV_64F).reshape(3, 0).copyTo(vp);
982 std::const_mem_fun_ref_t<cv::Point3d, MxArray>(
983 &MxArray::toPoint3_<double>));
991 std::vector<cv::Size> vs;
995 toMat(CV_32S).reshape(2, 0).copyTo(vs);
1008 std::vector<cv::Rect> vr;
1012 toMat(CV_32S).reshape(4, 0).copyTo(vr);
1025 std::vector<cv::Vec2i> vv;
1027 vv.push_back(toVec<int,2>());
1029 toMat(CV_32S).reshape(2, 0).copyTo(vv);
1034 std::const_mem_fun_ref_t<cv::Vec2i, MxArray>(
1035 &MxArray::toVec<int,2>));
1043 std::vector<cv::Vec2f> vv;
1045 vv.push_back(toVec<float,2>());
1047 toMat(CV_32F).reshape(2, 0).copyTo(vv);
1052 std::const_mem_fun_ref_t<cv::Vec2f, MxArray>(
1053 &MxArray::toVec<float,2>));
1061 std::vector<cv::Vec3i> vv;
1063 vv.push_back(toVec<int,3>());
1065 toMat(CV_32S).reshape(3, 0).copyTo(vv);
1070 std::const_mem_fun_ref_t<cv::Vec3i, MxArray>(
1071 &MxArray::toVec<int,3>));
1079 std::vector<cv::Vec3f> vv;
1081 vv.push_back(toVec<float,3>());
1083 toMat(CV_32F).reshape(3, 0).copyTo(vv);
1088 std::const_mem_fun_ref_t<cv::Vec3f, MxArray>(
1089 &MxArray::toVec<float,3>));
1097 std::vector<cv::Vec4i> vv;
1099 vv.push_back(toVec<int,4>());
1101 toMat(CV_32S).reshape(4, 0).copyTo(vv);
1106 std::const_mem_fun_ref_t<cv::Vec4i, MxArray>(
1107 &MxArray::toVec<int,4>));
1115 std::vector<cv::Vec4f> vv;
1117 vv.push_back(toVec<float,4>());
1119 toMat(CV_32F).reshape(4, 0).copyTo(vv);
1124 std::const_mem_fun_ref_t<cv::Vec4f, MxArray>(
1125 &MxArray::toVec<float,4>));
1132 const mwSize n =
numel();
1133 std::vector<cv::RotatedRect> v;
1136 for (mwIndex i = 0; i < n; ++i)
1137 v.push_back(at<MxArray>(i).toRotatedRect());
1139 for (mwIndex i = 0; i < n; ++i)
1142 mexErrMsgIdAndTxt(
"mexopencv:error",
1143 "MxArray unable to convert to std::vector<cv::RotatedRect>");
1150 const mwSize n =
numel();
1151 std::vector<cv::KeyPoint> v;
1154 for (mwIndex i = 0; i < n; ++i)
1155 v.push_back(at<MxArray>(i).toKeyPoint());
1157 for (mwIndex i = 0; i < n; ++i)
1160 mexErrMsgIdAndTxt(
"mexopencv:error",
1161 "MxArray unable to convert to std::vector<cv::KeyPoint>");
1168 const mwSize n =
numel();
1169 std::vector<cv::DMatch> v;
1172 for (mwIndex i = 0; i < n; ++i)
1173 v.push_back(at<MxArray>(i).toDMatch());
1175 for (mwIndex i = 0; i < n; ++i)
1178 mexErrMsgIdAndTxt(
"mexopencv:error",
1179 "MxArray unable to convert to std::vector<cv::DMatch>");
bool isSparse() const
Determine whether input is sparse array.
bool isStruct() const
Determine whether input is structure array.
cv::MatND toMatND(int depth=CV_USRTYPE1, bool transpose=true) const
Convert MxArray to a single-channel cv::Mat.
cv::Point2f toPoint2f() const
Alias to toPoint_<float>.
cv::Size toSize() const
Alias to toSize_<int>.
mwIndex subs(mwIndex i, mwIndex j=0) const
Offset from first element to desired element.
std::vector< std::string > fieldnames() const
Get field names of a struct array.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
bool isChar() const
Determine whether input is string array.
cv::RotatedRect toRotatedRect(mwIndex index=0) const
Convert MxArray to cv::RotatedRect.
int MexErrorHandler(int status, const char *func_name, const char *err_msg, const char *file_name, int line, void *)
Cutom error callback to be invoked by cv::error(), CV_Assert, etc...
double toDouble() const
Convert MxArray to double.
int toInt() const
Convert MxArray to int.
mxClassID classID() const
Class ID of mxArray.
cv::Range toRange() const
Convert MxArray to cv::Range.
cv::Point toPoint() const
Alias to toPoint_<int>.
float toFloat() const
Convert MxArray to float.
std::vector< T > toVector() const
Convert MxArray to std::vector<T> of primitive types.
cv::DMatch toDMatch(mwIndex index=0) const
Convert MxArray to cv::DMatch.
MxArray and ConstMap declaration.
bool isComplex() const
Determine whether data is complex.
mxArray object wrapper for data conversion and manipulation.
cv::Point3f toPoint3f() const
Alias to toPoint3_<float>.
bool toBool() const
Convert MxArray to bool.
cv::TermCriteria toTermCriteria(mwIndex index=0) const
Convert MxArray to cv::TermCriteria.
bool isNull() const
Determine whether the array is initialized or not.
cv::Moments toMoments(mwIndex index=0) const
Convert MxArray to cv::Moments.
bool isField(const std::string &fieldName) const
Determine whether a struct array has a specified field.
std::string fieldname(int fieldnumber) const
Get specified field name from a struct array.
bool isLogical() const
Determine whether array is of type mxLogical.
cv::KeyPoint toKeyPoint(mwIndex index=0) const
Convert MxArray to cv::KeyPoint.
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*.
mwSize ndims() const
Number of dimensions.
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.
std::map wrapper with one-line initialization and lookup method.
MxArray clone() const
Clone mxArray.
const mwSize * dims() const
Array of each dimension.
std::string toString() const
Convert MxArray to std::string.
cv::SparseMat toSparseMat(int depth=CV_USRTYPE1) const
Convert double sparse MxArray to 2D single-channel cv::SparseMat.
cv::Mat toMat(int depth=CV_USRTYPE1, bool transpose=true) const
Convert MxArray to cv::Mat.
bool isNumeric() const
Determine whether array is numeric.
mwSize rows() const
Number of rows in an array.
MxArray & operator=(const MxArray &rhs)
Assignment operator.
mwSize cols() const
Number of columns in an array.
bool isCell() const
Determine whether input is cell array.