mexopencv  3.4.1
MEX interface for OpenCV library
compare.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
15  ("eq", cv::CMP_EQ)
16  ("gt", cv::CMP_GT)
17  ("ge", cv::CMP_GE)
18  ("lt", cv::CMP_LT)
19  ("le", cv::CMP_LE)
20  ("ne", cv::CMP_NE);
21 }
22 
30 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
31 {
32  // Check the number of arguments
33  nargchk(nrhs==3 && nlhs<=1);
34 
35  // Argument vector
36  vector<MxArray> rhs(prhs, prhs+nrhs);
37 
38  // Process
39  Mat src1(rhs[0].toMat()),
40  src2(rhs[1].toMat()),
41  dst;
42  int cmpop = CompTypesMap[rhs[2].toString()];
43  compare(src1, src2, dst, cmpop);
44  plhs[0] = MxArray(dst);
45 }
STL namespace.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: compare.cpp:30
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
const ConstMap< string, int > CompTypesMap
comparison types map of relational operators for option processing
Definition: compare.cpp:14
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
STL class.
void compare(InputArray src1, InputArray src2, OutputArray dst, int cmpop)
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
cv::Mat toMat() const