mexopencv  3.4.1
MEX interface for OpenCV library
decomposeEssentialMat.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 {
20 MxArray toStruct(const Mat& R1, const Mat& R2, const Mat& t)
21 {
22  const char* fieldnames[] = {"R1", "R2", "t"};
23  MxArray s = MxArray::Struct(fieldnames, 3);
24  s.set("R1", R1);
25  s.set("R2", R2);
26  s.set("t", t);
27  return s;
28 }
29 }
30 
38 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
39 {
40  // Check the number of arguments
41  nargchk(nrhs==1 && nlhs<=1);
42 
43  // Argument vector
44  vector<MxArray> rhs(prhs, prhs+nrhs);
45 
46  // Process
47  Mat E(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
48  R1, R2, t;
49  decomposeEssentialMat(E, R1, R2, t);
50  plhs[0] = toStruct(R1, R2, t);
51 }
MxArray toStruct(const Mat &R1, const Mat &R2, const Mat &t)
Create a new MxArray from decomposed essential matrix.
STL namespace.
void decomposeEssentialMat(InputArray E, OutputArray R1, OutputArray R2, OutputArray t)
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
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
#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
STL class.
Global constant definitions.
cv::Mat toMat() const