mexopencv  3.4.1
MEX interface for OpenCV library
calibrationMatrixValues.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 {
22 MxArray toStruct(double fovx, double fovy, double focalLength,
23  const Point2d& principalPoint, double aspectRatio)
24 {
25  const char* fieldnames[] = {
26  "fovx", "fovy", "focalLength", "principalPoint", "aspectRatio"};
27  MxArray s = MxArray::Struct(fieldnames, 5);
28  s.set("fovx", fovx);
29  s.set("fovy", fovy);
30  s.set("focalLength", focalLength);
31  s.set("principalPoint", principalPoint);
32  s.set("aspectRatio", aspectRatio);
33  return s;
34 }
35 }
36 
44 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
45 {
46  // Check the number of arguments
47  nargchk(nrhs==4 && nlhs<=1);
48 
49  // Argument vector
50  vector<MxArray> rhs(prhs, prhs+nrhs);
51 
52  // Process
53  Mat cameraMatrix(rhs[0].toMat(CV_64F));
54  Size imageSize(rhs[1].toSize());
55  double apertureWidth = rhs[2].toDouble(),
56  apertureHeight = rhs[3].toDouble(),
57  fovx, fovy, focalLength, aspectRatio;
58  Point2d principalPoint;
59  calibrationMatrixValues(cameraMatrix, imageSize,
60  apertureWidth, apertureHeight,
61  fovx, fovy, focalLength, principalPoint, aspectRatio);
62  plhs[0] = toStruct(fovx, fovy, focalLength, principalPoint, aspectRatio);
63 }
STL namespace.
MxArray toStruct(double fovx, double fovy, double focalLength, const Point2d &principalPoint, double aspectRatio)
Create a new MxArray from characteristics of camera matrix.
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_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.
STL class.
Global constant definitions.
void calibrationMatrixValues(InputArray cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double &fovx, double &fovy, double &focalLength, Point2d &principalPoint, double &aspectRatio)
cv::Mat toMat() const