mexopencv  0.1
mex interface for opencv library
RQDecomp3x3.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
20 MxArray toStruct(const Mat& Qx, const Mat& Qy, const Mat& Qz,
21  const Vec3d& eulerAngles)
22 {
23  const char* fieldnames[] = {"Qx", "Qy", "Qz", "eulerAngles"};
24  MxArray s = MxArray::Struct(fieldnames, 4);
25  s.set("Qx", Qx);
26  s.set("Qy", Qy);
27  s.set("Qz", Qz);
28  s.set("eulerAngles", eulerAngles);
29  return s;
30 }
31 }
32 
40 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
41 {
42  // Check the number of arguments
43  nargchk(nrhs==1 && nlhs<=3);
44 
45  // Argument vector
46  vector<MxArray> rhs(prhs, prhs+nrhs);
47 
48  // Process
49  Mat M(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
50  R, Q, Qx, Qy, Qz;
51  Vec3d eulerAngles = RQDecomp3x3(M, R, Q,
52  (nlhs>2 ? Qx : noArray()),
53  (nlhs>2 ? Qy : noArray()),
54  (nlhs>2 ? Qz : noArray()));
55  plhs[0] = MxArray(R);
56  if (nlhs>1)
57  plhs[1] = MxArray(Q);
58  if (nlhs>2)
59  plhs[2] = toStruct(Qx, Qy, Qz, eulerAngles);
60 }
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.
Definition: RQDecomp3x3.cpp:40
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.