mexopencv  0.1
mex interface for opencv library
composeRT.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
26 MxArray toStruct(const Mat& rvec3, const Mat& tvec3, const Mat& dr3dr1,
27  const Mat& dr3dt1, const Mat& dr3dr2, const Mat& dr3dt2, const Mat& dt3dr1,
28  const Mat& dt3dt1, const Mat& dt3dr2, const Mat& dt3dt2)
29 {
30  const char* fieldnames[] = {"rvec3", "tvec3", "dr3dr1", "dr3dt1",
31  "dr3dr2", "dr3dt2", "dt3dr1", "dt3dt1", "dt3dr2", "dt3dt2"};
32  MxArray s = MxArray::Struct(fieldnames, 10);
33  s.set("rvec3", rvec3);
34  s.set("tvec3", tvec3);
35  s.set("dr3dr1", dr3dr1);
36  s.set("dr3dt1", dr3dt1);
37  s.set("dr3dr2", dr3dr2);
38  s.set("dr3dt2", dr3dt2);
39  s.set("dt3dr1", dt3dr1);
40  s.set("dt3dt1", dt3dt1);
41  s.set("dt3dr2", dt3dr2);
42  s.set("dt3dt2", dt3dt2);
43  return s;
44 }
45 }
46 
54 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
55 {
56  // Check the number of arguments
57  nargchk(nrhs==4 && nlhs<=1);
58 
59  // Argument vector
60  vector<MxArray> rhs(prhs, prhs+nrhs);
61 
62  // Process
63  Mat rvec1(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
64  tvec1(rhs[1].toMat(rhs[1].isSingle() ? CV_32F : CV_64F)),
65  rvec2(rhs[2].toMat(rhs[2].isSingle() ? CV_32F : CV_64F)),
66  tvec2(rhs[3].toMat(rhs[3].isSingle() ? CV_32F : CV_64F)),
67  rvec3, tvec3,
68  dr3dr1, dr3dt1, dr3dr2, dr3dt2,
69  dt3dr1, dt3dt1, dt3dr2, dt3dt2;
70  composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3,
71  dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2);
72  plhs[0] = toStruct(rvec3, tvec3,
73  dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2);
74 }
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.
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
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: composeRT.cpp:54
Global constant definitions.