mexopencv  3.4.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/output arguments number check. More...
 
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::Size_< T > > MxArrayToVectorSize (const MxArray &arr)
 Convert an MxArray to std::vector<cv::Size_<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::stringClassNameInvMap
 Translates data type definition used in OpenCV to that of MATLAB. More...
 
const ConstMap< std::string, cv::ScalarColorType
 Translates MATLAB color names (see ColorSpec) into OpenCV scalars. More...
 
const ConstMap< std::string, int > BorderType
 Border type map for option processing. More...
 
const ConstMap< int, std::stringBorderTypeInv
 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::stringDistTypeInv
 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::stringNormTypeInv
 Inverse norm type map for option processing. More...
 

Detailed Description

Global constant definitions.

Author
Kota Yamaguchi
Date
2012

Header file for MATLAB MEX-functions that use 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

◆ UPDATE_FLAG

#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 174 of file mexopencv.hpp.

Function Documentation

◆ MxArrayToVectorMatx()

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:

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

Definition at line 420 of file mexopencv.hpp.

◆ MxArrayToVectorPoint()

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:

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

Definition at line 208 of file mexopencv.hpp.

◆ MxArrayToVectorPoint3()

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:

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

Definition at line 250 of file mexopencv.hpp.

◆ MxArrayToVectorRect()

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:

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

Definition at line 335 of file mexopencv.hpp.

◆ MxArrayToVectorSize()

template<typename T >
std::vector<cv::Size_<T> > MxArrayToVectorSize ( const MxArray arr)

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

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

Example:

MxArray cellArray(prhs[0]);
vector<Size2d> vs = MxArrayToVectorSize<double>(cellArray);

Definition at line 292 of file mexopencv.hpp.

◆ MxArrayToVectorVec()

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:

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

Definition at line 378 of file mexopencv.hpp.

◆ MxArrayToVectorVectorPoint()

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:

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

Definition at line 496 of file mexopencv.hpp.

◆ MxArrayToVectorVectorPoint3()

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:

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

Definition at line 532 of file mexopencv.hpp.

◆ MxArrayToVectorVectorPrimitive()

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:

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

Definition at line 463 of file mexopencv.hpp.

◆ nargchk()

void nargchk ( bool  cond)
inline

Alias for input/output arguments number check.

Definition at line 181 of file mexopencv.hpp.

Variable Documentation

◆ BorderType

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)
BORDER_REPLICATE
BORDER_REFLECT
BORDER_REFLECT_101
BORDER_TRANSPARENT
BORDER_CONSTANT
BORDER_DEFAULT
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
BORDER_WRAP

Border type map for option processing.

Definition at line 66 of file mexopencv.hpp.

◆ BorderTypeInv

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")
BORDER_REPLICATE
BORDER_REFLECT
BORDER_REFLECT_101
BORDER_TRANSPARENT
BORDER_CONSTANT
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
BORDER_WRAP

Inverse border type map for option processing.

Definition at line 76 of file mexopencv.hpp.

◆ ClassNameInvMap

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")
#define CV_8U
#define CV_64F
#define CV_16U
#define CV_32S
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.

◆ ClassNameMap

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)
#define CV_8U
#define CV_64F
#define CV_16U
#define CV_32S
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.

◆ ColorType

const ConstMap<std::string,cv::Scalar> ColorType
Initial value:
("r", cv::Scalar( 0, 0,255))
("g", cv::Scalar( 0,255, 0))
("b", cv::Scalar(255, 0, 0))
("c", cv::Scalar(255,255, 0))
("m", cv::Scalar(255, 0,255))
("y", cv::Scalar( 0,255,255))
("k", cv::Scalar( 0, 0, 0))
("w", cv::Scalar(255,255,255))
Scalar_< double > Scalar
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927

Translates MATLAB color names (see ColorSpec) into OpenCV scalars.

Parameters
nameshort name of MATLAB colors. One of eight predefined colors.
Returns
BGR triplet as an OpenCV Scalar.

Definition at line 55 of file mexopencv.hpp.

◆ DistType

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)
DIST_HUBER
DIST_USER
DIST_WELSCH
DIST_L12
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
DIST_FAIR

Distance types for Distance Transform and M-estimators.

Definition at line 102 of file mexopencv.hpp.

◆ DistTypeInv

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")
DIST_HUBER
DIST_USER
DIST_WELSCH
DIST_L12
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
DIST_FAIR

Inverse Distance types for Distance Transform and M-estimators.

Definition at line 113 of file mexopencv.hpp.

◆ FontFace

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)
FONT_HERSHEY_COMPLEX_SMALL
FONT_HERSHEY_SCRIPT_SIMPLEX
FONT_HERSHEY_COMPLEX
FONT_HERSHEY_DUPLEX
FONT_HERSHEY_TRIPLEX
FONT_HERSHEY_SIMPLEX
FONT_HERSHEY_PLAIN
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
FONT_HERSHEY_SCRIPT_COMPLEX

Font faces for drawing.

Definition at line 134 of file mexopencv.hpp.

◆ FontStyle

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

Font styles for drawing.

Definition at line 145 of file mexopencv.hpp.

◆ InterpType

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)
("LinearExact", cv::INTER_LINEAR_EXACT)
INTER_CUBIC
INTER_LANCZOS4
INTER_AREA
INTER_LINEAR
INTER_NEAREST
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
INTER_LINEAR_EXACT

Interpolation type map for option processing.

Definition at line 85 of file mexopencv.hpp.

◆ LineType

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 124 of file mexopencv.hpp.

◆ NormType

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)
NORM_HAMMING
NORM_INF
NORM_HAMMING2
NORM_L2SQR
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 150 of file mexopencv.hpp.

◆ NormTypeInv

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")
NORM_HAMMING
NORM_INF
NORM_HAMMING2
NORM_L2SQR
NORM_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 160 of file mexopencv.hpp.

◆ ThicknessType

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 130 of file mexopencv.hpp.

◆ ThreshType

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)
THRESH_TRUNC
THRESH_TOZERO_INV
THRESH_TOZERO
THRESH_BINARY
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
THRESH_BINARY_INV

Thresholding type map for option processing.

Definition at line 94 of file mexopencv.hpp.