mexopencv  3.4.1
MEX interface for OpenCV library
RQDecomp3x3.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 {
21 MxArray toStruct(const Mat& Qx, const Mat& Qy, const Mat& Qz,
22  const Vec3d& eulerAngles)
23 {
24  const char* fieldnames[] = {"Qx", "Qy", "Qz", "eulerAngles"};
25  MxArray s = MxArray::Struct(fieldnames, 4);
26  s.set("Qx", Qx);
27  s.set("Qy", Qy);
28  s.set("Qz", Qz);
29  s.set("eulerAngles", eulerAngles);
30  return s;
31 }
32 }
33 
41 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
42 {
43  // Check the number of arguments
44  nargchk(nrhs==1 && nlhs<=3);
45 
46  // Argument vector
47  vector<MxArray> rhs(prhs, prhs+nrhs);
48 
49  // Process
50  Mat M(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
51  R, Q, Qx, Qy, Qz;
52  Vec3d eulerAngles = RQDecomp3x3(M, R, Q,
53  (nlhs>2 ? Qx : noArray()),
54  (nlhs>2 ? Qy : noArray()),
55  (nlhs>2 ? Qz : noArray()));
56  plhs[0] = MxArray(R);
57  if (nlhs>1)
58  plhs[1] = MxArray(Q);
59  if (nlhs>2)
60  plhs[2] = toStruct(Qx, Qy, Qz, eulerAngles);
61 }
STL namespace.
Vec3d RQDecomp3x3(InputArray src, OutputArray mtxR, OutputArray mtxQ, OutputArray Qx=noArray(), OutputArray Qy=noArray(), OutputArray Qz=noArray())
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
#define CV_32F
InputOutputArray noArray()
#define CV_64F
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: RQDecomp3x3.cpp:41
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
STL class.
MxArray toStruct(const Mat &Qx, const Mat &Qy, const Mat &Qz, const Vec3d &eulerAngles)
Create a new MxArray from decomposed matrix.
Definition: RQDecomp3x3.cpp:21
Global constant definitions.
cv::Mat toMat() const