11 #ifndef __MEXOPENCV_HPP__ 12 #define __MEXOPENCV_HPP__ 53 (
"Constant", cv::BORDER_CONSTANT)
54 (
"Replicate", cv::BORDER_REPLICATE)
55 (
"Reflect", cv::BORDER_REFLECT)
56 (
"Reflect101", cv::BORDER_REFLECT_101)
57 (
"Wrap", cv::BORDER_WRAP)
58 (
"Transparent", cv::BORDER_TRANSPARENT)
59 (
"Default", cv::BORDER_DEFAULT);
63 (cv::BORDER_CONSTANT,
"Constant")
64 (cv::BORDER_REPLICATE,
"Replicate")
65 (cv::BORDER_REFLECT,
"Reflect")
66 (cv::BORDER_REFLECT_101,
"Reflect101")
67 (cv::BORDER_WRAP,
"Wrap")
68 (cv::BORDER_TRANSPARENT,
"Transparent");
72 (
"Nearest", cv::INTER_NEAREST)
73 (
"Linear", cv::INTER_LINEAR)
74 (
"Cubic", cv::INTER_CUBIC)
75 (
"Area", cv::INTER_AREA)
76 (
"Lanczos4", cv::INTER_LANCZOS4);
80 (
"Binary", cv::THRESH_BINARY)
81 (
"BinaryInv", cv::THRESH_BINARY_INV)
82 (
"Trunc", cv::THRESH_TRUNC)
83 (
"ToZero", cv::THRESH_TOZERO)
84 (
"ToZeroInv", cv::THRESH_TOZERO_INV);
88 (
"User", cv::DIST_USER)
93 (
"Fair", cv::DIST_FAIR)
94 (
"Welsch", cv::DIST_WELSCH)
95 (
"Huber", cv::DIST_HUBER);
99 (cv::DIST_USER,
"User")
103 (cv::DIST_L12,
"L12")
104 (cv::DIST_FAIR,
"Fair")
105 (cv::DIST_WELSCH,
"Welsch")
106 (cv::DIST_HUBER,
"Huber");
116 (
"Filled", cv::FILLED);
120 (
"HersheySimplex", cv::FONT_HERSHEY_SIMPLEX)
121 (
"HersheyPlain", cv::FONT_HERSHEY_PLAIN)
122 (
"HersheyDuplex", cv::FONT_HERSHEY_DUPLEX)
123 (
"HersheyComplex", cv::FONT_HERSHEY_COMPLEX)
124 (
"HersheyTriplex", cv::FONT_HERSHEY_TRIPLEX)
125 (
"HersheyComplexSmall", cv::FONT_HERSHEY_COMPLEX_SMALL)
126 (
"HersheyScriptSimplex", cv::FONT_HERSHEY_SCRIPT_SIMPLEX)
127 (
"HersheyScriptComplex", cv::FONT_HERSHEY_SCRIPT_COMPLEX);
132 (
"Italic", cv::FONT_ITALIC);
136 (
"Inf", cv::NORM_INF)
139 (
"L2Sqr", cv::NORM_L2SQR)
140 (
"Hamming", cv::NORM_HAMMING)
141 (
"Hamming2", cv::NORM_HAMMING2)
142 (
"MinMax", cv::NORM_MINMAX);
146 (cv::NORM_INF,
"Inf")
149 (cv::NORM_L2SQR,
"L2Sqr")
150 (cv::NORM_HAMMING,
"Hamming")
151 (cv::NORM_HAMMING2,
"Hamming2")
152 (cv::NORM_MINMAX,
"MinMax");
159 #define UPDATE_FLAG(NUM, TF, BIT) \ 161 if ((TF)) { (NUM) |= (BIT); } \ 162 else { (NUM) &= ~(BIT); } \ 169 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
192 template <
typename T>
195 std::vector<cv::Point_<T> > vp;
197 if (arr.
numel() == 2)
200 arr.
toMat(cv::DataType<T>::depth).reshape(2, 0).copyTo(vp);
210 std::const_mem_fun_ref_t<cv::Point_<T>,
MxArray>(
211 &MxArray::toPoint_<T>));
214 mexErrMsgIdAndTxt(
"mexopencv:error",
215 "Unable to convert MxArray to std::vector<cv::Point_<T>>");
234 template <
typename T>
237 std::vector<cv::Point3_<T> > vp;
239 if (arr.
numel() == 3)
242 arr.
toMat(cv::DataType<T>::depth).reshape(3, 0).copyTo(vp);
252 std::const_mem_fun_ref_t<cv::Point3_<T>,
MxArray>(
253 &MxArray::toPoint3_<T>));
256 mexErrMsgIdAndTxt(
"mexopencv:error",
257 "Unable to convert MxArray to std::vector<cv::Point3_<T>>");
277 template <
typename T>
280 std::vector<cv::Rect_<T> > vr;
282 if (arr.
numel() == 4)
283 vr.push_back(arr.
toRect_<T>());
285 arr.
toMat(cv::DataType<T>::depth).reshape(4, 0).copyTo(vr);
295 std::const_mem_fun_ref_t<cv::Rect_<T>,
MxArray>(
296 &MxArray::toRect_<T>));
299 mexErrMsgIdAndTxt(
"mexopencv:error",
300 "Unable to convert MxArray to std::vector<cv::Rect_<T>>");
320 template <
typename T,
int cn>
323 std::vector<cv::Vec<T,cn> > vv;
325 if (arr.
numel() == cn)
326 vv.push_back(arr.
toVec<T,cn>());
328 arr.
toMat(cv::Vec<T,cn>::depth).reshape(cn, 0).copyTo(vv);
338 std::const_mem_fun_ref_t<cv::Vec<T,cn>,
MxArray>(
339 &MxArray::toVec<T,cn>));
342 mexErrMsgIdAndTxt(
"mexopencv:error",
343 "Unable to convert MxArray to std::vector<cv::Vec<T,cn>>");
362 template <
typename T,
int m,
int n>
365 std::vector<cv::Matx<T,m,n> > vx;
367 vx.push_back(arr.
toMatx<T,m,n>());
377 std::const_mem_fun_ref_t<cv::Matx<T,m,n>,
MxArray>(
378 &MxArray::toMatx<T,m,n>));
381 mexErrMsgIdAndTxt(
"mexopencv:error",
382 "Unable to convert MxArray to std::vector<cv::Matx<T,m,n>>");
405 template <
typename T>
417 typedef std::vector<T> VecT;
418 std::const_mem_fun_ref_t<VecT, MxArray> func(&MxArray::toVector<T>);
438 template <
typename T>
442 std::vector<std::vector<cv::Point_<T> > > vvp;
443 vvp.reserve(vva.size());
444 for (std::vector<MxArray>::const_iterator it = vva.begin(); it != vva.end(); ++it) {
453 vvp.push_back(MxArrayToVectorPoint<T>(*it));
474 template <
typename T>
478 std::vector<std::vector<cv::Point3_<T> > > vvp;
479 vvp.reserve(vva.size());
480 for (std::vector<MxArray>::const_iterator it = vva.begin(); it != vva.end(); ++it) {
489 vvp.push_back(MxArrayToVectorPoint3<T>(*it));
const ConstMap< std::string, int > FontStyle
Font styles for drawing.
const ConstMap< std::string, int > ClassNameMap
Translates class name used in MATLAB to equivalent OpenCV depth.
cv::Point_< T > toPoint_() const
Convert MxArray to Point_<T>.
std::vector< cv::Vec< T, cn > > MxArrayToVectorVec(const MxArray &arr)
Convert an MxArray to std::vector<cv::Vec<T,cn>>
const ConstMap< std::string, int > InterpType
Interpolation type map for option processing.
const ConstMap< std::string, int > ThreshType
Thresholding type map for option processing.
const ConstMap< int, std::string > NormTypeInv
Inverse norm type map for option processing.
std::vector< cv::Point_< T > > MxArrayToVectorPoint(const MxArray &arr)
Convert an MxArray to std::vector<cv::Point_<T>>
const ConstMap< int, std::string > DistTypeInv
Inverse Distance types for Distance Transform and M-estimators.
const ConstMap< int, std::string > BorderTypeInv
Inverse border type map for option processing.
std::vector< T > toVector() const
Convert MxArray to std::vector<T> of primitive types.
std::vector< std::vector< cv::Point3_< T > > > MxArrayToVectorVectorPoint3(const MxArray &arr)
Convert an MxArray to std::vector<std::vector<cv::Point3_<T>>>
const ConstMap< std::string, int > BorderType
Border type map for option processing.
MxArray and ConstMap declaration.
cv::Vec< T, cn > toVec() const
Convert MxArray to Vec<T,cn>.
const ConstMap< std::string, int > LineType
Line type for drawing.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
const ConstMap< std::string, int > DistType
Distance types for Distance Transform and M-estimators.
cv::Point3_< T > toPoint3_() const
Convert MxArray to Point3_<T>.
const ConstMap< std::string, int > ThicknessType
Thickness type for drawing.
const ConstMap< int, std::string > ClassNameInvMap
Translates data type definition used in OpenCV to that of MATLAB.
std::vector< std::vector< cv::Point_< T > > > MxArrayToVectorVectorPoint(const MxArray &arr)
Convert an MxArray to std::vector<std::vector<cv::Point_<T>>>
cv::Matx< T, m, n > toMatx() const
Convert MxArray to Matx<T,m,n>.
mwSize numel() const
Number of elements in an array.
cv::Rect_< T > toRect_() const
Convert MxArray to Rect_<T>.
std::vector< std::vector< T > > MxArrayToVectorVectorPrimitive(const MxArray &arr)
Convert an MxArray to std::vector<std::vector<T>>
std::map wrapper with one-line initialization and lookup method.
std::vector< cv::Point3_< T > > MxArrayToVectorPoint3(const MxArray &arr)
Convert an MxArray to std::vector<cv::Point3_<T>>
std::vector< cv::Matx< T, m, n > > MxArrayToVectorMatx(const MxArray &arr)
Convert an MxArray to std::vector<cv::Matx<T,m,n>>
const ConstMap< std::string, int > NormType
Norm type map for option processing.
cv::Mat toMat(int depth=CV_USRTYPE1, bool transpose=true) const
Convert MxArray to cv::Mat.
std::vector< cv::Rect_< T > > MxArrayToVectorRect(const MxArray &arr)
Convert an MxArray to std::vector<cv::Rect_<T>>
bool isNumeric() const
Determine whether array is numeric.
const ConstMap< std::string, int > FontFace
Font faces for drawing.
bool isCell() const
Determine whether input is cell array.