mexopencv  3.4.1
MEX interface for OpenCV library
stereoRectifyUncalibrated.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 && (nrhs%2)==0 && nlhs<=3);
24 
25  // Argument vector
26  vector<MxArray> rhs(prhs, prhs+nrhs);
27 
28  // Option processing
29  double threshold = 5;
30  for (int i=4; i<nrhs; i+=2) {
31  string key(rhs[i].toString());
32  if (key == "Threshold")
33  threshold = rhs[i+1].toDouble();
34  else
35  mexErrMsgIdAndTxt("mexopencv:error",
36  "Unrecognized option %s", key.c_str());
37  }
38 
39  // Process
40  Mat F(rhs[2].toMat(CV_64F));
41  Size imgSize(rhs[3].toSize());
42  Mat H1, H2;
43  bool b = false;
44  if (rhs[0].isNumeric() && rhs[1].isNumeric()) {
45  Mat points1(rhs[0].toMat(CV_64F)),
46  points2(rhs[1].toMat(CV_64F));
47  b = stereoRectifyUncalibrated(points1, points2, F, imgSize, H1, H2,
48  threshold);
49  }
50  else if (rhs[0].isCell() && rhs[1].isCell()) {
51  vector<Point2d> points1(rhs[0].toVector<Point2d>()),
52  points2(rhs[1].toVector<Point2d>());
53  b = stereoRectifyUncalibrated(points1, points2, F, imgSize, H1, H2,
54  threshold);
55  }
56  plhs[0] = MxArray(H1);
57  if (nlhs>1)
58  plhs[1] = MxArray(H2);
59  if (nlhs>2)
60  plhs[2] = MxArray(b);
61 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
#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.
Global constant definitions.
T c_str(T... args)
double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
bool stereoRectifyUncalibrated(InputArray points1, InputArray points2, InputArray F, Size imgSize, OutputArray H1, OutputArray H2, double threshold=5)
cv::Mat toMat() const