mexopencv  3.4.1
MEX interface for OpenCV library
composeRT.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 
13 namespace {
27 MxArray toStruct(const Mat& rvec3, const Mat& tvec3, const Mat& dr3dr1,
28  const Mat& dr3dt1, const Mat& dr3dr2, const Mat& dr3dt2, const Mat& dt3dr1,
29  const Mat& dt3dt1, const Mat& dt3dr2, const Mat& dt3dt2)
30 {
31  const char* fieldnames[] = {"rvec3", "tvec3", "dr3dr1", "dr3dt1",
32  "dr3dr2", "dr3dt2", "dt3dr1", "dt3dt1", "dt3dr2", "dt3dt2"};
33  MxArray s = MxArray::Struct(fieldnames, 10);
34  s.set("rvec3", rvec3);
35  s.set("tvec3", tvec3);
36  s.set("dr3dr1", dr3dr1);
37  s.set("dr3dt1", dr3dt1);
38  s.set("dr3dr2", dr3dr2);
39  s.set("dr3dt2", dr3dt2);
40  s.set("dt3dr1", dt3dr1);
41  s.set("dt3dt1", dt3dt1);
42  s.set("dt3dr2", dt3dr2);
43  s.set("dt3dt2", dt3dt2);
44  return s;
45 }
46 }
47 
55 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
56 {
57  // Check the number of arguments
58  nargchk(nrhs==4 && nlhs<=1);
59 
60  // Argument vector
61  vector<MxArray> rhs(prhs, prhs+nrhs);
62 
63  // Process
64  Mat rvec1(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
65  tvec1(rhs[1].toMat(rhs[1].isSingle() ? CV_32F : CV_64F)),
66  rvec2(rhs[2].toMat(rhs[2].isSingle() ? CV_32F : CV_64F)),
67  tvec2(rhs[3].toMat(rhs[3].isSingle() ? CV_32F : CV_64F)),
68  rvec3, tvec3,
69  dr3dr1, dr3dt1, dr3dr2, dr3dt2,
70  dt3dr1, dt3dt1, dt3dr2, dt3dt2;
71  composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3,
72  dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2);
73  plhs[0] = toStruct(rvec3, tvec3,
74  dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2);
75 }
void composeRT(InputArray rvec1, InputArray tvec1, InputArray rvec2, InputArray tvec2, OutputArray rvec3, OutputArray tvec3, OutputArray dr3dr1=noArray(), OutputArray dr3dt1=noArray(), OutputArray dr3dr2=noArray(), OutputArray dr3dt2=noArray(), OutputArray dt3dr1=noArray(), OutputArray dt3dt1=noArray(), OutputArray dt3dr2=noArray(), OutputArray dt3dt2=noArray())
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
Definition: MxArray.hpp:1310
MxArray toStruct(const Mat &rvec3, const Mat &tvec3, const Mat &dr3dr1, const Mat &dr3dt1, const Mat &dr3dr2, const Mat &dr3dt2, const Mat &dt3dr1, const Mat &dt3dt1, const Mat &dt3dr2, const Mat &dt3dt2)
Create a new MxArray from combined transformations.
Definition: composeRT.cpp:27
#define CV_32F
#define CV_64F
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
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:55
STL class.
Global constant definitions.
cv::Mat toMat() const