mexopencv  0.1
mex interface for opencv library
decomposeEssentialMat.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 Mat& R1, const Mat& R2, const Mat& t)
20 {
21  const char* fieldnames[] = {"R1", "R2", "t"};
22  MxArray s = MxArray::Struct(fieldnames, 3);
23  s.set("R1", R1);
24  s.set("R2", R2);
25  s.set("t", t);
26  return s;
27 }
28 }
29 
37 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
38 {
39  // Check the number of arguments
40  nargchk(nrhs==1 && nlhs<=1);
41 
42  // Argument vector
43  vector<MxArray> rhs(prhs, prhs+nrhs);
44 
45  // Process
46  Mat E(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
47  R1, R2, t;
48  decomposeEssentialMat(E, R1, R2, t);
49  plhs[0] = toStruct(R1, R2, t);
50 }
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
Definition: MxArray.hpp:1310
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
MxArray toStruct(const std::vector< cv::ml::DTrees::Node > &nodes)
Convert tree nodes to struct array.
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.