mexopencv  0.1
mex interface for opencv library
decomposeHomographyMat.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
19 MxArray toStruct(const vector<Mat>& rotations,
20  const vector<Mat>& translations, const vector<Mat>& normals)
21 {
22  const char* fieldnames[] = {"R", "t", "n"};
23  MxArray s = MxArray::Struct(fieldnames, 3);
24  s.set("R", rotations);
25  s.set("t", translations);
26  s.set("n", normals);
27  return s;
28 }
29 }
30 
38 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
39 {
40  // Check the number of arguments
41  nargchk(nrhs==2 && nlhs<=2);
42 
43  // Argument vector
44  vector<MxArray> rhs(prhs, prhs+nrhs);
45 
46  // Process
47  Mat H(rhs[0].toMat(CV_64F)),
48  K(rhs[1].toMat(CV_64F));
49  vector<Mat> rotations, translations, normals;
50  int nsols = decomposeHomographyMat(H, K, rotations, translations, normals);
51  plhs[0] = toStruct(rotations, translations, normals);
52  if (nlhs > 1)
53  plhs[1] = MxArray(nsols);
54 }
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
Definition: MxArray.hpp:1310
MxArray toStruct(const std::vector< cv::ml::DTrees::Node > &nodes)
Convert tree nodes to struct array.
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/ouput arguments number check.
Definition: mexopencv.hpp:166
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
Definition: MxArray.hpp:312
Global constant definitions.