mexopencv  0.1
mex interface for opencv library
calibrationMatrixValues.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
21 MxArray toStruct(double fovx, double fovy, double focalLength,
22  const Point2d& principalPoint, double aspectRatio)
23 {
24  const char* fieldnames[] = {
25  "fovx", "fovy", "focalLength", "principalPoint", "aspectRatio"};
26  MxArray s = MxArray::Struct(fieldnames, 5);
27  s.set("fovx", fovx);
28  s.set("fovy", fovy);
29  s.set("focalLength", focalLength);
30  s.set("principalPoint", principalPoint);
31  s.set("aspectRatio", aspectRatio);
32  return s;
33 }
34 }
35 
43 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
44 {
45  // Check the number of arguments
46  nargchk(nrhs==4 && nlhs<=1);
47 
48  // Argument vector
49  vector<MxArray> rhs(prhs, prhs+nrhs);
50 
51  // Process
52  Mat cameraMatrix(rhs[0].toMat(CV_64F));
53  Size imageSize(rhs[1].toSize());
54  double apertureWidth = rhs[2].toDouble(),
55  apertureHeight = rhs[3].toDouble(),
56  fovx, fovy, focalLength, aspectRatio;
57  Point2d principalPoint;
58  calibrationMatrixValues(cameraMatrix, imageSize,
59  apertureWidth, apertureHeight,
60  fovx, fovy, focalLength, principalPoint, aspectRatio);
61  plhs[0] = toStruct(fovx, fovy, focalLength, principalPoint, aspectRatio);
62 }
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.
Global constant definitions.