mexopencv  3.4.1
MEX interface for OpenCV library
triangulatePoints.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/calib3d.hpp"
10 using namespace std;
11 using namespace cv;
12 
20 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
21 {
22  // Check the number of arguments
23  nargchk(nrhs==4 && nlhs<=1);
24 
25  // Argument vector
26  vector<MxArray> rhs(prhs, prhs+nrhs);
27 
28  // Process
29  Mat projMatr1(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
30  projMatr2(rhs[1].toMat(rhs[1].isSingle() ? CV_32F : CV_64F)),
31  points4D;
32  if (rhs[2].isNumeric() && rhs[3].isNumeric()) {
33  Mat projPoints1(rhs[2].toMat(rhs[2].isSingle() ? CV_32F : CV_64F)),
34  projPoints2(rhs[3].toMat(rhs[3].isSingle() ? CV_32F : CV_64F));
35  triangulatePoints(projMatr1, projMatr2, projPoints1, projPoints2,
36  points4D);
37  }
38  else if (rhs[2].isCell() && rhs[3].isCell()) {
39  vector<Point2d> projPoints1(rhs[2].toVector<Point2d>()),
40  projPoints2(rhs[3].toVector<Point2d>());
41  triangulatePoints(projMatr1, projMatr2, projPoints1, projPoints2,
42  points4D);
43  }
44  else
45  mexErrMsgIdAndTxt("mexopencv:error", "Invalid points argument");
46  plhs[0] = MxArray(points4D); // 4xN
47 }
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
#define CV_32F
#define CV_64F
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
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 mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
void triangulatePoints(InputArray projMatr1, InputArray projMatr2, InputArray projPoints1, InputArray projPoints2, OutputArray points4D)
Global constant definitions.
cv::Mat toMat() const