mexopencv  0.1
mex interface for opencv library
Macros | Functions | Variables
mexopencv.hpp File Reference

Global constant definitions. More...

#include "MxArray.hpp"

Go to the source code of this file.

Macros

#define UPDATE_FLAG(NUM, TF, BIT)
 set or clear a bit in flag depending on bool value More...
 

Functions

void nargchk (bool cond)
 Alias for input/ouput arguments number check.
 
template<typename T >
std::vector< cv::Point_< T > > MxArrayToVectorPoint (const MxArray &arr)
 Convert an MxArray to std::vector<cv::Point_<T>> More...
 
template<typename T >
std::vector< cv::Point3_< T > > MxArrayToVectorPoint3 (const MxArray &arr)
 Convert an MxArray to std::vector<cv::Point3_<T>> More...
 
template<typename T >
std::vector< cv::Rect_< T > > MxArrayToVectorRect (const MxArray &arr)
 Convert an MxArray to std::vector<cv::Rect_<T>> More...
 
template<typename T , int cn>
std::vector< cv::Vec< T, cn > > MxArrayToVectorVec (const MxArray &arr)
 Convert an MxArray to std::vector<cv::Vec<T,cn>> More...
 
template<typename T , int m, int n>
std::vector< cv::Matx< T, m, n > > MxArrayToVectorMatx (const MxArray &arr)
 Convert an MxArray to std::vector<cv::Matx<T,m,n>> More...
 
template<typename T >
std::vector< std::vector< T > > MxArrayToVectorVectorPrimitive (const MxArray &arr)
 Convert an MxArray to std::vector<std::vector<T>> More...
 
template<typename T >
std::vector< std::vector< cv::Point_< T > > > MxArrayToVectorVectorPoint (const MxArray &arr)
 Convert an MxArray to std::vector<std::vector<cv::Point_<T>>> More...
 
template<typename T >
std::vector< std::vector< cv::Point3_< T > > > MxArrayToVectorVectorPoint3 (const MxArray &arr)
 Convert an MxArray to std::vector<std::vector<cv::Point3_<T>>> More...
 

Variables

const ConstMap< std::string, int > ClassNameMap
 Translates class name used in MATLAB to equivalent OpenCV depth. More...
 
const ConstMap< int, std::string > ClassNameInvMap
 Translates data type definition used in OpenCV to that of MATLAB. More...
 
const ConstMap< std::string, int > BorderType
 Border type map for option processing. More...
 
const ConstMap< int, std::string > BorderTypeInv
 Inverse border type map for option processing. More...
 
const ConstMap< std::string, int > InterpType
 Interpolation type map for option processing. More...
 
const ConstMap< std::string, int > ThreshType
 Thresholding type map for option processing. More...
 
const ConstMap< std::string, int > DistType
 Distance types for Distance Transform and M-estimators. More...
 
const ConstMap< int, std::string > DistTypeInv
 Inverse Distance types for Distance Transform and M-estimators. More...
 
const ConstMap< std::string, int > LineType
 Line type for drawing. More...
 
const ConstMap< std::string, int > ThicknessType
 Thickness type for drawing. More...
 
const ConstMap< std::string, int > FontFace
 Font faces for drawing. More...
 
const ConstMap< std::string, int > FontStyle
 Font styles for drawing. More...
 
const ConstMap< std::string, int > NormType
 Norm type map for option processing. More...
 
const ConstMap< int, std::string > NormTypeInv
 Inverse norm type map for option processing. More...
 

Detailed Description

Global constant definitions.

Author
Kota Yamaguchi
Date
2012

The header file for a MATLAB MEX-function that uses OpenCV library. The file includes definition of MxArray class that converts between mxArray and a couple of std:: and cv:: data types including cv::Mat.

Definition in file mexopencv.hpp.

Macro Definition Documentation

#define UPDATE_FLAG (   NUM,
  TF,
  BIT 
)
Value:
do { \
if ((TF)) { (NUM) |= (BIT); } \
else { (NUM) &= ~(BIT); } \
} while(0)

set or clear a bit in flag depending on bool value

Definition at line 159 of file mexopencv.hpp.

Function Documentation

template<typename T , int m, int n>
std::vector<cv::Matx<T,m,n> > MxArrayToVectorMatx ( const MxArray arr)

Convert an MxArray to std::vector<cv::Matx<T,m,n>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of mats (mxn matrices) of length N, e.g: {[mat_11, ..., mat_1n; ....; mat_m1, ..., mat_mn], ...}
  • a sole numeric matrix (N=1) of size mxn in the form: [mat_11, ..., mat_1n; ....; mat_m1, ..., mat_mn]
Returns
vector of mats of size N

Example:

1 MxArray cellArray(prhs[0]);
2 vector<Matx32f> vx = MxArrayToVectorMatx<float,3,2>(cellArray);

Definition at line 363 of file mexopencv.hpp.

template<typename T >
std::vector<cv::Point_<T> > MxArrayToVectorPoint ( const MxArray arr)

Convert an MxArray to std::vector<cv::Point_<T>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of 2D points (2-element vectors) of length N, e.g: {[x,y], [x,y], ...}
  • a numeric matrix of size Nx2, Nx1x2, or 1xNx2 in the form: [x,y; x,y; ...] or cat(3, [x,y], [x,y], ...)
Returns
vector of 2D points of size N

Example:

1 MxArray cellArray(prhs[0]);
2 vector<Point2d> vp = MxArrayToVectorPoint<double>(cellArray);

Definition at line 193 of file mexopencv.hpp.

template<typename T >
std::vector<cv::Point3_<T> > MxArrayToVectorPoint3 ( const MxArray arr)

Convert an MxArray to std::vector<cv::Point3_<T>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of 3D points (3-element vectors) of length N, e.g: {[x,y,z], [x,y,z], ...}
  • a numeric matrix of size Nx3, Nx1x3, or 1xNx3 in the form: [x,y,z; x,y,z; ...] or cat(3, [x,y,z], [x,y,z], ...)
Returns
vector of 3D points of size N

Example:

1 MxArray cellArray(prhs[0]);
2 vector<Point3f> vp = MxArrayToVectorPoint3<float>(cellArray);

Definition at line 235 of file mexopencv.hpp.

template<typename T >
std::vector<cv::Rect_<T> > MxArrayToVectorRect ( const MxArray arr)

Convert an MxArray to std::vector<cv::Rect_<T>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of rectangles (4-element vectors) of length N, e.g: {[x,y,w,h], [x,y,w,h], ...}
  • a numeric matrix of size Nx4, Nx1x4, or 1xNx4 in the form: [x,y,w,h; x,y,w,h; ...] or cat(3, [x,y,w,h], [x,y,w,h], ...)
Returns
vector of rectangles of size N

Example:

1 MxArray cellArray(prhs[0]);
2 vector<Rect2f> vr = MxArrayToVectorRect<float>(cellArray);

Definition at line 278 of file mexopencv.hpp.

template<typename T , int cn>
std::vector<cv::Vec<T,cn> > MxArrayToVectorVec ( const MxArray arr)

Convert an MxArray to std::vector<cv::Vec<T,cn>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of vecs (cn -element vectors) of length N, e.g: {[v_1,v_2,...,v_cn], [v_1,v_2,...,v_cn], ...}
  • a numeric matrix of size Nxcn, Nx1xcn, or 1xNxcn in the form: [v_1,v_2,...,v_cn; v_1,v_2,...,v_cn; ...] or cat(3, [v_1,v_2,...,v_cn], [v_1,v_2,...,v_cn], ...)
Returns
vector of vecs of size N

Example:

1 MxArray cellArray(prhs[0]);
2 vector<Vec4i> vv = MxArrayToVectorVec<int,4>(cellArray);

Definition at line 321 of file mexopencv.hpp.

template<typename T >
std::vector<std::vector<cv::Point_<T> > > MxArrayToVectorVectorPoint ( const MxArray arr)

Convert an MxArray to std::vector<std::vector<cv::Point_<T>>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of cell-arrays of 2D points (2-element vectors), e.g: {{[x,y], [x,y], ..}, {[x,y], [x,y], ..}, ...}
  • a cell-array of numeric matrices of size Mx2, Mx1x2, or 1xMx2, e.g: {[x,y; x,y; ...], [x,y; x,y; ...], ...} or {cat(3, [x,y], [x,y], ...), cat(3, [x,y], [x,y], ...), ...}
Returns
vector of vectors of 2D points

Example:

1 MxArray cellArray(prhs[0]);
2 vector<vector<Point2d>> vvp = MxArrayToVectorVectorPoint<double>(cellArray);

Definition at line 439 of file mexopencv.hpp.

template<typename T >
std::vector<std::vector<cv::Point3_<T> > > MxArrayToVectorVectorPoint3 ( const MxArray arr)

Convert an MxArray to std::vector<std::vector<cv::Point3_<T>>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of cell-arrays of 3D points (3-element vectors), e.g: {{[x,y,z], [x,y,z], ..}, {[x,y,z], [x,y,z], ..}, ...}
  • a cell-array of numeric matrices of size Mx3, Mx1x3, or 1xMx3, e.g: {[x,y,z; x,y,z; ...], [x,y,z; x,y,z; ...], ...} or {cat(3, [x,y,z], [x,y,z], ...), cat(3, [x,y,z], [x,y,z], ...), ...}
Returns
vector of vectors of 3D points

Example:

1 MxArray cellArray(prhs[0]);
2 vector<vector<Point3d>> vvp = MxArrayToVectorVectorPoint3<double>(cellArray);

Definition at line 475 of file mexopencv.hpp.

template<typename T >
std::vector<std::vector<T> > MxArrayToVectorVectorPrimitive ( const MxArray arr)

Convert an MxArray to std::vector<std::vector<T>>

Parameters
arrMxArray object. In one of the following forms:
  • a cell-array of cell-arrays of numeric scalars, e.g: {{s1, s2, ...}, {s1, ...}, ...}
  • a cell-array of numeric vectors, e.g: {[s1, s2, ...], [s1, ...], ...}
Returns
vector of vectors of primitives of type T

Example:

1 MxArray cellArray(prhs[0]);
2 vector<vector<int>> vvi = MxArrayToVectorVectorPrimitive<int>(cellArray);

Definition at line 406 of file mexopencv.hpp.

Variable Documentation

const ConstMap<std::string,int> BorderType
Initial value:
("Constant", cv::BORDER_CONSTANT)
("Replicate", cv::BORDER_REPLICATE)
("Reflect", cv::BORDER_REFLECT)
("Reflect101", cv::BORDER_REFLECT_101)
("Wrap", cv::BORDER_WRAP)
("Transparent", cv::BORDER_TRANSPARENT)
("Default", cv::BORDER_DEFAULT)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Border type map for option processing.

Definition at line 52 of file mexopencv.hpp.

const ConstMap<int,std::string> BorderTypeInv
Initial value:
(cv::BORDER_CONSTANT, "Constant")
(cv::BORDER_REPLICATE, "Replicate")
(cv::BORDER_REFLECT, "Reflect")
(cv::BORDER_REFLECT_101, "Reflect101")
(cv::BORDER_WRAP, "Wrap")
(cv::BORDER_TRANSPARENT, "Transparent")
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Inverse border type map for option processing.

Definition at line 62 of file mexopencv.hpp.

const ConstMap<int,std::string> ClassNameInvMap
Initial value:
(CV_8U, "uint8")
(CV_8S, "int8")
(CV_16U, "uint16")
(CV_16S, "int16")
(CV_32S, "int32")
(CV_32F, "single")
(CV_64F, "double")
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Translates data type definition used in OpenCV to that of MATLAB.

Parameters
depthOpenCV cv::Mat data depth, e.g. CV_8U.
Returns
equivalent MATLAB class name, e.g. uint8.

Definition at line 42 of file mexopencv.hpp.

const ConstMap<std::string,int> ClassNameMap
Initial value:
("uint8", CV_8U)
("int8", CV_8S)
("uint16", CV_16U)
("int16", CV_16S)
("int32", CV_32S)
("single", CV_32F)
("double", CV_64F)
("logical", CV_8U)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Translates class name used in MATLAB to equivalent OpenCV depth.

Parameters
classnamenumeric MATLAB data type, e.g. uint8.
Returns
equivalent OpenCV data type, e.g. CV_8U.

Note: 64-bit integer types are not supported by OpenCV. Also, OpenCV only has signed 32-bit integer type.

Definition at line 27 of file mexopencv.hpp.

const ConstMap<std::string,int> DistType
Initial value:
("User", cv::DIST_USER)
("L1", cv::DIST_L1)
("L2", cv::DIST_L2)
("C", cv::DIST_C)
("L12", cv::DIST_L12)
("Fair", cv::DIST_FAIR)
("Welsch", cv::DIST_WELSCH)
("Huber", cv::DIST_HUBER)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Distance types for Distance Transform and M-estimators.

Definition at line 87 of file mexopencv.hpp.

const ConstMap<int,std::string> DistTypeInv
Initial value:
(cv::DIST_USER, "User")
(cv::DIST_L1, "L1")
(cv::DIST_L2, "L2")
(cv::DIST_C, "C")
(cv::DIST_L12, "L12")
(cv::DIST_FAIR, "Fair")
(cv::DIST_WELSCH, "Welsch")
(cv::DIST_HUBER, "Huber")
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Inverse Distance types for Distance Transform and M-estimators.

Definition at line 98 of file mexopencv.hpp.

const ConstMap<std::string,int> FontFace
Initial value:
("HersheySimplex", cv::FONT_HERSHEY_SIMPLEX)
("HersheyPlain", cv::FONT_HERSHEY_PLAIN)
("HersheyDuplex", cv::FONT_HERSHEY_DUPLEX)
("HersheyComplex", cv::FONT_HERSHEY_COMPLEX)
("HersheyTriplex", cv::FONT_HERSHEY_TRIPLEX)
("HersheyComplexSmall", cv::FONT_HERSHEY_COMPLEX_SMALL)
("HersheyScriptSimplex", cv::FONT_HERSHEY_SCRIPT_SIMPLEX)
("HersheyScriptComplex", cv::FONT_HERSHEY_SCRIPT_COMPLEX)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Font faces for drawing.

Definition at line 119 of file mexopencv.hpp.

const ConstMap<std::string,int> FontStyle
Initial value:
("Regular", 0)
("Italic", cv::FONT_ITALIC)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Font styles for drawing.

Definition at line 130 of file mexopencv.hpp.

const ConstMap<std::string,int> InterpType
Initial value:
("Nearest", cv::INTER_NEAREST)
("Linear", cv::INTER_LINEAR)
("Cubic", cv::INTER_CUBIC)
("Area", cv::INTER_AREA)
("Lanczos4", cv::INTER_LANCZOS4)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Interpolation type map for option processing.

Definition at line 71 of file mexopencv.hpp.

const ConstMap<std::string,int> LineType
Initial value:
("4", cv::LINE_4)
("8", cv::LINE_8)
("AA", cv::LINE_AA)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Line type for drawing.

Definition at line 109 of file mexopencv.hpp.

const ConstMap<std::string,int> NormType
Initial value:
("Inf", cv::NORM_INF)
("L1", cv::NORM_L1)
("L2", cv::NORM_L2)
("L2Sqr", cv::NORM_L2SQR)
("Hamming", cv::NORM_HAMMING)
("Hamming2", cv::NORM_HAMMING2)
("MinMax", cv::NORM_MINMAX)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Norm type map for option processing.

Definition at line 135 of file mexopencv.hpp.

const ConstMap<int,std::string> NormTypeInv
Initial value:
(cv::NORM_INF, "Inf")
(cv::NORM_L1, "L1")
(cv::NORM_L2, "L2")
(cv::NORM_L2SQR, "L2Sqr")
(cv::NORM_HAMMING, "Hamming")
(cv::NORM_HAMMING2, "Hamming2")
(cv::NORM_MINMAX, "MinMax")
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Inverse norm type map for option processing.

Definition at line 145 of file mexopencv.hpp.

const ConstMap<std::string,int> ThicknessType
Initial value:
("Filled", cv::FILLED)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Thickness type for drawing.

Definition at line 115 of file mexopencv.hpp.

const ConstMap<std::string,int> ThreshType
Initial value:
("Binary", cv::THRESH_BINARY)
("BinaryInv", cv::THRESH_BINARY_INV)
("Trunc", cv::THRESH_TRUNC)
("ToZero", cv::THRESH_TOZERO)
("ToZeroInv", cv::THRESH_TOZERO_INV)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Thresholding type map for option processing.

Definition at line 79 of file mexopencv.hpp.