mexopencv  3.4.1
MEX interface for OpenCV library
rotatedRectangleIntersection.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/imgproc.hpp"
10 using namespace std;
11 using namespace cv;
12 
13 namespace {
16  (cv::INTERSECT_NONE, "None")
17  (cv::INTERSECT_PARTIAL, "Partial")
18  (cv::INTERSECT_FULL, "Full");
19 }
20 
28 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
29 {
30  // Check the number of arguments
31  nargchk(nrhs==2 && nlhs<=2);
32 
33  // Argument vector
34  vector<MxArray> rhs(prhs, prhs+nrhs);
35 
36  // Process
37  RotatedRect rect1(rhs[0].toRotatedRect()),
38  rect2(rhs[1].toRotatedRect());
39  vector<Point2f> intersection;
40  int result = rotatedRectangleIntersection(rect1, rect2, intersection);
41  plhs[0] = MxArray(intersection);
42  if (nlhs > 1)
43  plhs[1] = MxArray(RectIntersectInvMap[result]);
44 }
const ConstMap< int, string > RectIntersectInvMap
types of intersection between rectangles
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
INTERSECT_PARTIAL
INTERSECT_FULL
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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.
Global constant definitions.
INTERSECT_NONE
int rotatedRectangleIntersection(const RotatedRect &rect1, const RotatedRect &rect2, OutputArray intersectingRegion)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927