mexopencv  0.1
mex interface for opencv library
triangulatePoints.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
19 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
20 {
21  // Check the number of arguments
22  nargchk(nrhs==4 && nlhs<=1);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Process
28  Mat projMatr1(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
29  projMatr2(rhs[1].toMat(rhs[1].isSingle() ? CV_32F : CV_64F)),
30  points4D;
31  if (rhs[2].isNumeric() && rhs[3].isNumeric()) {
32  Mat projPoints1(rhs[2].toMat(rhs[2].isSingle() ? CV_32F : CV_64F)),
33  projPoints2(rhs[3].toMat(rhs[3].isSingle() ? CV_32F : CV_64F));
34  triangulatePoints(projMatr1, projMatr2, projPoints1, projPoints2,
35  points4D);
36  }
37  else if (rhs[2].isCell() && rhs[3].isCell()) {
38  vector<Point2d> projPoints1(rhs[2].toVector<Point2d>()),
39  projPoints2(rhs[3].toVector<Point2d>());
40  triangulatePoints(projMatr1, projMatr2, projPoints1, projPoints2,
41  points4D);
42  }
43  else
44  mexErrMsgIdAndTxt("mexopencv:error", "Invalid input");
45  plhs[0] = MxArray(points4D); // 4xN
46 }
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Global constant definitions.