mexopencv  0.1
mex interface for opencv library
Public Member Functions | Static Public Member Functions | List of all members
MxArray Class Reference

mxArray object wrapper for data conversion and manipulation. More...

#include <MxArray.hpp>

Public Member Functions

 MxArray (const mxArray *arr)
 MxArray constructor from mxArray*. More...
 
 MxArray (const MxArray &arr)
 Copy constructor. More...
 
MxArrayoperator= (const MxArray &rhs)
 Assignment operator. More...
 
 MxArray (const int i)
 MxArray constructor from int. More...
 
 MxArray (const double d)
 MxArray constructor from double. More...
 
 MxArray (const bool b)
 MxArray constructor from bool. More...
 
 MxArray (const std::string &s)
 MxArray constructor from std::string. More...
 
 MxArray (const cv::Mat &mat, mxClassID classid=mxUNKNOWN_CLASS, bool transpose=true)
 Convert cv::Mat to MxArray. More...
 
 MxArray (const cv::SparseMat &mat)
 Convert float cv::SparseMat to MxArray. More...
 
 MxArray (const cv::Moments &m)
 Convert cv::Moments to MxArray. More...
 
 MxArray (const cv::KeyPoint &p)
 Convert cv::KeyPoint to MxArray. More...
 
 MxArray (const cv::DMatch &m)
 Convert cv::DMatch to MxArray. More...
 
 MxArray (const cv::RotatedRect &r)
 Convert cv::RotatedRect to MxArray. More...
 
 MxArray (const cv::TermCriteria &t)
 Convert cv::TermCriteria to MxArray. More...
 
template<typename T >
 MxArray (const std::vector< T > &v)
 MxArray constructor from vector<T>. More...
 
template<typename T >
 MxArray (const cv::Point_< T > &p)
 MxArray constructor from cv::Point_<T>. More...
 
template<typename T >
 MxArray (const cv::Point3_< T > &p)
 MxArray constructor from cv::Point3_<T>. More...
 
template<typename T >
 MxArray (const cv::Size_< T > &s)
 MxArray constructor from cv::Size_<T>. More...
 
template<typename T >
 MxArray (const cv::Rect_< T > &r)
 MxArray constructor from cv::Rect_<T>. More...
 
template<typename T >
 MxArray (const cv::Scalar_< T > &s)
 MxArray constructor from cv::Scalar_<T>. More...
 
template<typename T , int cn>
 MxArray (const cv::Vec< T, cn > &vec)
 MxArray constructor from cv::Vec<T,cn>. More...
 
template<typename T , int m, int n>
 MxArray (const cv::Matx< T, m, n > &mat)
 MxArray constructor from cv::Matx<T,m,n>. More...
 
virtual ~MxArray ()
 Destructor. More...
 
MxArray clone () const
 Clone mxArray. More...
 
void destroy ()
 Deallocate memory occupied by mxArray. More...
 
 operator const mxArray * () const
 Implicit conversion to const mxArray*. More...
 
 operator mxArray * () const
 Implicit conversion to mxArray*. More...
 
int toInt () const
 Convert MxArray to int. More...
 
double toDouble () const
 Convert MxArray to double. More...
 
float toFloat () const
 Convert MxArray to float. More...
 
bool toBool () const
 Convert MxArray to bool. More...
 
std::string toString () const
 Convert MxArray to std::string. More...
 
cv::Mat toMat (int depth=CV_USRTYPE1, bool transpose=true) const
 Convert MxArray to cv::Mat. More...
 
cv::MatND toMatND (int depth=CV_USRTYPE1, bool transpose=true) const
 Convert MxArray to a single-channel cv::Mat. More...
 
cv::SparseMat toSparseMat (int depth=CV_USRTYPE1) const
 Convert double sparse MxArray to 2D single-channel cv::SparseMat. More...
 
cv::Moments toMoments (mwIndex index=0) const
 Convert MxArray to cv::Moments. More...
 
cv::KeyPoint toKeyPoint (mwIndex index=0) const
 Convert MxArray to cv::KeyPoint. More...
 
cv::DMatch toDMatch (mwIndex index=0) const
 Convert MxArray to cv::DMatch. More...
 
cv::Range toRange () const
 Convert MxArray to cv::Range. More...
 
cv::RotatedRect toRotatedRect (mwIndex index=0) const
 Convert MxArray to cv::RotatedRect. More...
 
cv::TermCriteria toTermCriteria (mwIndex index=0) const
 Convert MxArray to cv::TermCriteria. More...
 
template<typename T >
cv::Point_< T > toPoint_ () const
 Convert MxArray to Point_<T>. More...
 
template<typename T >
cv::Point3_< T > toPoint3_ () const
 Convert MxArray to Point3_<T>. More...
 
template<typename T >
cv::Size_< T > toSize_ () const
 Convert MxArray to Size_<T>. More...
 
template<typename T >
cv::Rect_< T > toRect_ () const
 Convert MxArray to Rect_<T>. More...
 
template<typename T >
cv::Scalar_< T > toScalar_ () const
 Convert MxArray to Scalar_<T>. More...
 
template<typename T , int cn>
cv::Vec< T, cn > toVec () const
 Convert MxArray to Vec<T,cn>. More...
 
template<typename T , int m, int n>
cv::Matx< T, m, n > toMatx () const
 Convert MxArray to Matx<T,m,n>. More...
 
template<typename T >
std::vector< T > toVector () const
 Convert MxArray to std::vector<T> of primitive types. More...
 
template<typename T >
std::vector< T > toVector (std::const_mem_fun_ref_t< T, MxArray > f) const
 Convert MxArray to std::vector<T> by a specified conversion method. More...
 
cv::Point toPoint () const
 Alias to toPoint_<int>. More...
 
cv::Point2f toPoint2f () const
 Alias to toPoint_<float>. More...
 
cv::Point3f toPoint3f () const
 Alias to toPoint3_<float>. More...
 
cv::Size toSize () const
 Alias to toSize_<int>. More...
 
cv::Rect toRect () const
 Alias to toRect_<int>. More...
 
cv::Scalar toScalar () const
 Alias to toScalar_<double> More...
 
mxClassID classID () const
 Class ID of mxArray. More...
 
const std::string className () const
 Class name of mxArray. More...
 
mwSize numel () const
 Number of elements in an array. More...
 
mwSize ndims () const
 Number of dimensions. More...
 
const mwSize * dims () const
 Array of each dimension. More...
 
mwSize rows () const
 Number of rows in an array. More...
 
mwSize cols () const
 Number of columns in an array. More...
 
int nfields () const
 Number of fields in a struct array. More...
 
std::string fieldname (int fieldnumber) const
 Get specified field name from a struct array. More...
 
std::vector< std::string > fieldnames () const
 Get field names of a struct array. More...
 
mwSize nzmax () const
 Number of elements in IR, PR, and PI arrays. More...
 
mwIndex subs (mwIndex i, mwIndex j=0) const
 Offset from first element to desired element. More...
 
mwIndex subs (const std::vector< mwIndex > &si) const
 Offset from first element to desired element. More...
 
bool isNull () const
 Determine whether the array is initialized or not. More...
 
bool isCell () const
 Determine whether input is cell array. More...
 
bool isChar () const
 Determine whether input is string array. More...
 
bool isClass (std::string s) const
 Determine whether array is member of specified class. More...
 
bool isComplex () const
 Determine whether data is complex. More...
 
bool isDouble () const
 Determine whether mxArray represents data as double-precision, floating-point numbers. More...
 
bool isEmpty () const
 Determine whether array is empty. More...
 
bool isFromGlobalWS () const
 Determine whether array was copied from MATLAB global workspace. More...
 
bool isInt8 () const
 Determine whether array represents data as signed 8-bit integers. More...
 
bool isInt16 () const
 Determine whether array represents data as signed 16-bit integers. More...
 
bool isInt32 () const
 Determine whether array represents data as signed 32-bit integers. More...
 
bool isInt64 () const
 Determine whether array represents data as signed 64-bit integers. More...
 
bool isLogical () const
 Determine whether array is of type mxLogical. More...
 
bool isLogicalScalar () const
 Determine whether scalar array is of type mxLogical. More...
 
bool isLogicalScalarTrue () const
 Determine whether scalar array of type mxLogical is true. More...
 
bool isNumeric () const
 Determine whether array is numeric. More...
 
bool isSingle () const
 Determine whether array represents data as single-precision, floating-point numbers. More...
 
bool isSparse () const
 Determine whether input is sparse array. More...
 
bool isStruct () const
 Determine whether input is structure array. More...
 
bool isUint8 () const
 Determine whether array represents data as unsigned 8-bit integers. More...
 
bool isUint16 () const
 Determine whether array represents data as unsigned 16-bit integers. More...
 
bool isUint32 () const
 Determine whether array represents data as unsigned 32-bit integers. More...
 
bool isUint64 () const
 Determine whether array represents data as unsigned 64-bit integers. More...
 
bool isInteger () const
 Determine whether array represents data as integer types (8-bit, 16-bit, 32-bit or 64-bit, both signed and unsigned). More...
 
bool isFloat () const
 Determine whether array represents data as floating-point numbers, both single and double precision. More...
 
bool isField (const std::string &fieldName) const
 Determine whether a struct array has a specified field. More...
 
template<typename T >
at (mwIndex index) const
 Template for numeric array element accessor. More...
 
template<typename T >
at (mwIndex i, mwIndex j) const
 Template for numeric array element accessor. More...
 
template<typename T >
at (const std::vector< mwIndex > &si) const
 Template for numeric array element accessor. More...
 
MxArray at (const std::string &fieldName, mwIndex index=0) const
 Struct array element accessor. More...
 
template<typename T >
void set (mwIndex index, const T &value)
 Template for numeric array element write accessor. More...
 
template<typename T >
void set (mwIndex i, mwIndex j, const T &value)
 Template for numeric array element write accessor. More...
 
template<typename T >
void set (const std::vector< mwIndex > &si, const T &value)
 Template for numeric array element write accessor. More...
 
template<typename T >
void set (const std::string &fieldName, const T &value, mwIndex index=0)
 Template for struct array element write accessor. More...
 
template<>
void fromVector (const std::vector< char > &v)
 MxArray specialized constructor from vector<char>. More...
 
template<>
void fromVector (const std::vector< bool > &v)
 MxArray specialized constructor from vector<bool>. More...
 
template<>
 MxArray (const std::vector< cv::DMatch > &v)
 MxArray specialized constructor from vector<DMatch>. More...
 
template<>
 MxArray (const std::vector< cv::KeyPoint > &v)
 MxArray specialized constructor from vector<KeyPoint>. More...
 
template<>
 MxArray (const std::vector< cv::RotatedRect > &v)
 MxArray specialized constructor from vector<RotatedRect>. More...
 
template<>
MxArray at (mwIndex index) const
 Cell array element accessor. More...
 
template<>
void set (mwIndex index, const MxArray &value)
 Cell array element write accessor. More...
 
template<>
std::vector< MxArraytoVector () const
 Convert MxArray to std::vector<MxArray>. More...
 
template<>
std::vector< std::string > toVector () const
 Convert MxArray to std::vector<std::string>. More...
 
template<>
std::vector< cv::Mat > toVector () const
 Convert MxArray to std::vector<cv::Mat>. More...
 
template<>
std::vector< cv::Point > toVector () const
 Convert MxArray to std::vector<Point>. More...
 
template<>
std::vector< cv::Point2f > toVector () const
 Convert MxArray to std::vector<Point2f>. More...
 
template<>
std::vector< cv::Point2d > toVector () const
 Convert MxArray to std::vector<Point2d>. More...
 
template<>
std::vector< cv::Point3i > toVector () const
 Convert MxArray to std::vector<Point3i>. More...
 
template<>
std::vector< cv::Point3f > toVector () const
 Convert MxArray to std::vector<Point3f>. More...
 
template<>
std::vector< cv::Point3d > toVector () const
 Convert MxArray to std::vector<Point3d>. More...
 
template<>
std::vector< cv::Size > toVector () const
 Convert MxArray to std::vector<Size>. More...
 
template<>
std::vector< cv::Rect > toVector () const
 Convert MxArray to std::vector<Rect>. More...
 
template<>
std::vector< cv::Vec2i > toVector () const
 Convert MxArray to std::vector<Vec2i>. More...
 
template<>
std::vector< cv::Vec2f > toVector () const
 Convert MxArray to std::vector<Vec2f>. More...
 
template<>
std::vector< cv::Vec3i > toVector () const
 Convert MxArray to std::vector<Vec3i>. More...
 
template<>
std::vector< cv::Vec3f > toVector () const
 Convert MxArray to std::vector<Vec3f>. More...
 
template<>
std::vector< cv::Vec4i > toVector () const
 Convert MxArray to std::vector<Vec4i>. More...
 
template<>
std::vector< cv::Vec4f > toVector () const
 Convert MxArray to std::vector<Vec4f>. More...
 
template<>
std::vector< cv::RotatedRect > toVector () const
 Convert MxArray to std::vector<cv::RotatedRect>. More...
 
template<>
std::vector< cv::KeyPoint > toVector () const
 Convert MxArray to std::vector<cv::KeyPoint>. More...
 
template<>
std::vector< cv::DMatch > toVector () const
 Convert MxArray to std::vector<cv::DMatch>. More...
 

Static Public Member Functions

static MxArray Cell (mwSize m=1, mwSize n=1)
 Create a new cell array. More...
 
static MxArray Struct (const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
 Create a new struct array. More...
 
static bool isFinite (double d)
 Determine whether input is finite. More...
 
static bool isInf (double d)
 Determine whether input is infinite. More...
 
static bool isNaN (double d)
 Determine whether input is NaN (Not-a-Number). More...
 
static double Inf ()
 Value of infinity. More...
 
static double NaN ()
 Value of NaN (Not-a-Number). More...
 
static double Eps ()
 Value of EPS. More...
 

Detailed Description

mxArray object wrapper for data conversion and manipulation.

Definition at line 123 of file MxArray.hpp.

Constructor & Destructor Documentation

MxArray::MxArray ( const mxArray *  arr)
inline

MxArray constructor from mxArray*.

Parameters
arrmxArray pointer given by mexFunction.

Definition at line 129 of file MxArray.hpp.

MxArray::MxArray ( const MxArray arr)
inline

Copy constructor.

Parameters
arrAnother MxArray.

Definition at line 133 of file MxArray.hpp.

MxArray::MxArray ( const int  i)
explicit

MxArray constructor from int.

Parameters
iint value.
Returns
MxArray object, a scalar double array.

Definition at line 109 of file MxArray.cpp.

MxArray::MxArray ( const double  d)
explicit

MxArray constructor from double.

Parameters
ddouble value.
Returns
MxArray object, a scalar double array.

Definition at line 116 of file MxArray.cpp.

MxArray::MxArray ( const bool  b)
explicit

MxArray constructor from bool.

Parameters
bbool value.
Returns
MxArray object, a scalar logical array.

Definition at line 123 of file MxArray.cpp.

MxArray::MxArray ( const std::string &  s)
explicit

MxArray constructor from std::string.

Parameters
sreference to a string value.
Returns
MxArray object.

Definition at line 130 of file MxArray.cpp.

MxArray::MxArray ( const cv::Mat &  mat,
mxClassID  classid = mxUNKNOWN_CLASS,
bool  transpose = true 
)
explicit

Convert cv::Mat to MxArray.

Parameters
matcv::Mat object.
classidclassid of mxArray. e.g., mxDOUBLE_CLASS. When mxUNKNOWN_CLASS is specified, classid will be automatically determined from the type of cv::Mat. default: mxUNKNOWN_CLASS.
transposeOptional transposition to the return value so that rows and columns of the 2D Mat are mapped to the 2nd and 1st dimensions in MxArray, respectively. This does not apply the N-D array conversion. default true.
Returns
MxArray object.

Convert cv::Mat object to an MxArray. When the cv::Mat object is 2D, the width, height, and channels are mapped to the first, second, and third dimensions of the MxArray unless transpose flag is set to false. When the cv::Mat object is N-D, (dim 1, dim 2,...dim N, channels) are mapped to (dim 2, dim 1, ..., dim N, dim N+1), respectively.

Example:

cv::Mat x(120, 90, CV_8UC3, Scalar(0));
mxArray* plhs[0] = MxArray(x);

Definition at line 196 of file MxArray.cpp.

MxArray::MxArray ( const cv::SparseMat &  mat)
explicit

Convert float cv::SparseMat to MxArray.

Parameters
matcv::SparseMat object.
Returns
MxArray object, a 2D sparse array.

Definition at line 265 of file MxArray.cpp.

MxArray::MxArray ( const cv::Moments &  m)
explicit

Convert cv::Moments to MxArray.

Parameters
mcv::Moments object.
Returns
MxArray object, a scalar struct array.

Definition at line 344 of file MxArray.cpp.

MxArray::MxArray ( const cv::KeyPoint &  p)
explicit

Convert cv::KeyPoint to MxArray.

Parameters
pcv::KeyPoint object.
Returns
MxArray object, a scalar struct array.

Definition at line 375 of file MxArray.cpp.

MxArray::MxArray ( const cv::DMatch &  m)
explicit

Convert cv::DMatch to MxArray.

Parameters
mcv::DMatch object.
Returns
MxArray object, a scalar struct array.

Definition at line 423 of file MxArray.cpp.

MxArray::MxArray ( const cv::RotatedRect &  r)
explicit

Convert cv::RotatedRect to MxArray.

Parameters
rcv::RotatedRect object.
Returns
MxArray object, a scalar struct array.

Definition at line 448 of file MxArray.cpp.

MxArray::MxArray ( const cv::TermCriteria &  t)
explicit

Convert cv::TermCriteria to MxArray.

Parameters
tcv::TermCriteria object.
Returns
MxArray object, a scalar struct array.

Definition at line 471 of file MxArray.cpp.

template<typename T >
MxArray::MxArray ( const std::vector< T > &  v)
inlineexplicit

MxArray constructor from vector<T>.

Parameters
vvector of type T.
Returns
MxArray object, a numeric or a cell array.

The constructor forwards the call to an appropriate overloaded method according to the paramter type (tag dispatching by instance). In the general case, vectors of primitive types are converted to numeric arrays of the equivalent MATLAB type, while other types are converted to cell arrays.

Example:

std::vector<double> v(10, 1.0);
mxArray* plhs[0] = MxArray(v);

Definition at line 231 of file MxArray.hpp.

template<typename T >
MxArray::MxArray ( const cv::Point_< T > &  p)
explicit

MxArray constructor from cv::Point_<T>.

Parameters
pcv::Point_<T> object.
Returns
two-element numeric MxArray [x, y].

Definition at line 974 of file MxArray.hpp.

template<typename T >
MxArray::MxArray ( const cv::Point3_< T > &  p)
explicit

MxArray constructor from cv::Point3_<T>.

Parameters
pcv::Point3_<T> object.
Returns
three-element numeric MxArray [x, y, z].

Definition at line 985 of file MxArray.hpp.

template<typename T >
MxArray::MxArray ( const cv::Size_< T > &  s)
explicit

MxArray constructor from cv::Size_<T>.

Parameters
scv::Size_<T> object.
Returns
two-element numeric MxArray.

Definition at line 997 of file MxArray.hpp.

template<typename T >
MxArray::MxArray ( const cv::Rect_< T > &  r)
explicit

MxArray constructor from cv::Rect_<T>.

Parameters
rcv::Rect_<T> object.
Returns
four-element numeric MxArray [x, y, width, height].

Definition at line 1008 of file MxArray.hpp.

template<typename T >
MxArray::MxArray ( const cv::Scalar_< T > &  s)
explicit

MxArray constructor from cv::Scalar_<T>.

Parameters
scv::Scalar_<T> object.
Returns
four-element numeric MxArray [v0, v1, v2, v3].

Definition at line 1021 of file MxArray.hpp.

template<typename T , int cn>
MxArray::MxArray ( const cv::Vec< T, cn > &  vec)
explicit

MxArray constructor from cv::Vec<T,cn>.

Parameters
veccv::Vec<T,cn> object.
Returns
cn -element numeric MxArray [v0, v1, ...].

Definition at line 1034 of file MxArray.hpp.

template<typename T , int m, int n>
MxArray::MxArray ( const cv::Matx< T, m, n > &  mat)
explicit

MxArray constructor from cv::Matx<T,m,n>.

Parameters
matcv::Mat<T,m,n> object.
Returns
m-by-n numeric MxArray matrix [mat_11, ..., mat_1n; ....; mat_m1, ..., mat_mn].

Definition at line 1049 of file MxArray.hpp.

virtual MxArray::~MxArray ( )
inlinevirtual

Destructor.

This does not free the underlying mxArray*.

Definition at line 277 of file MxArray.hpp.

MxArray::MxArray ( const std::vector< cv::DMatch > &  v)

MxArray specialized constructor from vector<DMatch>.

Parameters
vvector of type DMatch.
Returns
a struct array MxArray object.

Definition at line 435 of file MxArray.cpp.

MxArray::MxArray ( const std::vector< cv::KeyPoint > &  v)

MxArray specialized constructor from vector<KeyPoint>.

Parameters
vvector of type KeyPoint.
Returns
a struct array MxArray object.

Definition at line 408 of file MxArray.cpp.

MxArray::MxArray ( const std::vector< cv::RotatedRect > &  v)

MxArray specialized constructor from vector<RotatedRect>.

Parameters
vvector of type RotatedRect.
Returns
a struct array MxArray object.

Definition at line 459 of file MxArray.cpp.

Member Function Documentation

template<typename T >
T MxArray::at ( mwIndex  index) const

Template for numeric array element accessor.

Parameters
indexlinear index of the array element.
Returns
value of the element at specified index.

This getter method is intended for accessing elements of primitive types of a numeric array. Use an appropriate specialized/overloaded method version for accessing elements of struct or cell arrays.

In MATLAB, this is equivalent to getting:

value = arr(index)

Example:

MxArray m(prhs[0]);
double d = m.at<double>(0);

Definition at line 1250 of file MxArray.hpp.

template<typename T >
T MxArray::at ( mwIndex  i,
mwIndex  j 
) const

Template for numeric array element accessor.

Parameters
iindex of the first dimension.
jindex of the second dimension.
Returns
value of the element at (i,j) subscript.

This getter method is intended for accessing elements of primitive types of a numeric array.

In MATLAB, this is equivalent to getting:

value = arr(i,j)

Definition at line 1298 of file MxArray.hpp.

template<typename T >
T MxArray::at ( const std::vector< mwIndex > &  si) const

Template for numeric array element accessor.

Parameters
sivector of subscripts for each dimension of the array.
Returns
value of the element at subscript index.

This getter method is intended for accessing elements of primitive types of a numeric array.

In MATLAB, this is equivalent to getting:

value = arr(dim1Sub, dim2Sub, ,dim3Sub, ...)

Definition at line 1304 of file MxArray.hpp.

MxArray MxArray::at ( const std::string &  fieldName,
mwIndex  index = 0 
) const

Struct array element accessor.

Parameters
fieldNamename of field in the structure.
indexlinear index of the struct array element.
Returns
MxArray of the field at the specified index.

In MATLAB, this is equivalent to getting:

value = st(index).fieldname

Example:

MxArray structArray(prhs[0]);
MxArray x = structArray.at<MxArray>("some_field");

Definition at line 812 of file MxArray.cpp.

MxArray MxArray::at ( mwIndex  index) const

Cell array element accessor.

Parameters
indexlinear index of the cell array element.
Returns
MxArray of the element at the specified index.

Example:

MxArray cellArray(prhs[0]);
MxArray m = cellArray.at<MxArray>(0);

Definition at line 826 of file MxArray.cpp.

static MxArray MxArray::Cell ( mwSize  m = 1,
mwSize  n = 1 
)
inlinestatic

Create a new cell array.

Parameters
mNumber of rows.
nNumber of cols.
Returns
MxArray object, a 2D cell array with uninitialized cells.

Example:

c.set(0, MxArray(1));
c.set(1, MxArray(std::string("some value")));

Definition at line 290 of file MxArray.hpp.

mxClassID MxArray::classID ( ) const
inline

Class ID of mxArray.

Returns
identifier of the array class, enum value of type mxClassID.

Definition at line 535 of file MxArray.hpp.

const std::string MxArray::className ( ) const
inline

Class name of mxArray.

Returns
class name of the array, as a string.

Definition at line 539 of file MxArray.hpp.

MxArray MxArray::clone ( ) const

Clone mxArray.

This allocates new mxArray*.

Returns
MxArray object, a deep-copy clone.

Definition at line 481 of file MxArray.cpp.

mwSize MxArray::cols ( ) const
inline

Number of columns in an array.

Returns
number of cols in the array.

If the array is N-dimensional, this returns the product of dimensions 2 through N.

Definition at line 565 of file MxArray.hpp.

void MxArray::destroy ( )
inline

Deallocate memory occupied by mxArray.

Use this to destroy a temporary mxArray. Do not call this on arrays you are returning to MATLAB as left-hand side.

Definition at line 329 of file MxArray.hpp.

const mwSize* MxArray::dims ( ) const
inline

Array of each dimension.

Returns
array of dimensions, number of elements in each dimension.

Definition at line 554 of file MxArray.hpp.

static double MxArray::Eps ( )
inlinestatic

Value of EPS.

Returns
double-precision value representing MATLAB eps.

This variable holds the distance from 1.0 to the next largest floating-point number. As such, it is a measure of floating-point accuracy.

Definition at line 893 of file MxArray.hpp.

std::string MxArray::fieldname ( int  fieldnumber) const

Get specified field name from a struct array.

Parameters
fieldnumberposition of the desired field.
Returns
std::string name of n-th field.

Definition at line 775 of file MxArray.cpp.

std::vector< std::string > MxArray::fieldnames ( ) const

Get field names of a struct array.

Returns
std::vector<std::string> vector of all field names.

Definition at line 786 of file MxArray.cpp.

void MxArray::fromVector ( const std::vector< char > &  v)

MxArray specialized constructor from vector<char>.

Parameters
vvector of type char.
Returns
a char array MxArray object.

Definition at line 389 of file MxArray.cpp.

void MxArray::fromVector ( const std::vector< bool > &  v)

MxArray specialized constructor from vector<bool>.

Parameters
vvector of type bool.
Returns
a logical array MxArray object.

Definition at line 399 of file MxArray.cpp.

static double MxArray::Inf ( )
inlinestatic

Value of infinity.

Returns
double-precision value representing infinity.

Definition at line 881 of file MxArray.hpp.

bool MxArray::isCell ( ) const
inline

Determine whether input is cell array.

Returns
true if array is of type mxCELL_CLASS, false otherwise.

Definition at line 610 of file MxArray.hpp.

bool MxArray::isChar ( ) const
inline

Determine whether input is string array.

Returns
true if array is of type mxCHAR_CLASS, false otherwise.

Definition at line 614 of file MxArray.hpp.

bool MxArray::isClass ( std::string  s) const
inline

Determine whether array is member of specified class.

Parameters
sclass name as a string
Returns
true if array is of specified class, false otherwise.

Example:

bool b = MxArray(prhs[0]).isClass("uint8");

Definition at line 624 of file MxArray.hpp.

bool MxArray::isComplex ( ) const
inline

Determine whether data is complex.

Returns
true if array is numeric containing complex data, false otherwise

Definition at line 632 of file MxArray.hpp.

bool MxArray::isDouble ( ) const
inline

Determine whether mxArray represents data as double-precision, floating-point numbers.

Returns
true if array is of type mxDOUBLE_CLASS, false otherwise.

Definition at line 637 of file MxArray.hpp.

bool MxArray::isEmpty ( ) const
inline

Determine whether array is empty.

Returns
true if array is empty, false otherwise.

An array is empty if the size of any of its dimensions is 0.

Definition at line 643 of file MxArray.hpp.

bool MxArray::isField ( const std::string &  fieldName) const
inline

Determine whether a struct array has a specified field.

Parameters
fieldNamename of field to check
Returns
true if struct array has specified field, false otherwise.

Definition at line 743 of file MxArray.hpp.

static bool MxArray::isFinite ( double  d)
inlinestatic

Determine whether input is finite.

Parameters
ddouble-precision floating-point number
Returns
true if value is finite, false otherwise.

Definition at line 648 of file MxArray.hpp.

bool MxArray::isFloat ( ) const
inline

Determine whether array represents data as floating-point numbers, both single and double precision.

Returns
true for floating-point numeric arrays, false otherwise.

Definition at line 738 of file MxArray.hpp.

bool MxArray::isFromGlobalWS ( ) const
inline

Determine whether array was copied from MATLAB global workspace.

Returns
true if the array was copied out of the global workspace, false otherwise.

Definition at line 653 of file MxArray.hpp.

static bool MxArray::isInf ( double  d)
inlinestatic

Determine whether input is infinite.

Parameters
ddouble-precision floating-point number
Returns
true if value is infinity, false otherwise.

Definition at line 658 of file MxArray.hpp.

bool MxArray::isInt16 ( ) const
inline

Determine whether array represents data as signed 16-bit integers.

Returns
true if array is of type mxINT16_CLASS, false otherwise.

Definition at line 666 of file MxArray.hpp.

bool MxArray::isInt32 ( ) const
inline

Determine whether array represents data as signed 32-bit integers.

Returns
true if array is of type mxINT32_CLASS, false otherwise.

Definition at line 670 of file MxArray.hpp.

bool MxArray::isInt64 ( ) const
inline

Determine whether array represents data as signed 64-bit integers.

Returns
true if array is of type mxINT64_CLASS, false otherwise.

Definition at line 674 of file MxArray.hpp.

bool MxArray::isInt8 ( ) const
inline

Determine whether array represents data as signed 8-bit integers.

Returns
true if array is of type mxINT8_CLASS, false otherwise.

Definition at line 662 of file MxArray.hpp.

bool MxArray::isInteger ( ) const
inline

Determine whether array represents data as integer types (8-bit, 16-bit, 32-bit or 64-bit, both signed and unsigned).

Returns
true for integer numeric arrays, false otherwise.

Definition at line 729 of file MxArray.hpp.

bool MxArray::isLogical ( ) const
inline

Determine whether array is of type mxLogical.

Returns
true if array is of type mxLOGICAL_CLASS, false otherwise.

Definition at line 678 of file MxArray.hpp.

bool MxArray::isLogicalScalar ( ) const
inline

Determine whether scalar array is of type mxLogical.

Returns
true if array is 1-by-1 of type mxLOGICAL_CLASS, false otherwise.

Definition at line 683 of file MxArray.hpp.

bool MxArray::isLogicalScalarTrue ( ) const
inline

Determine whether scalar array of type mxLogical is true.

Returns
true if array is 1-by-1 of type mxLOGICAL_CLASS containing a value of true, returns false otherwise.

Definition at line 688 of file MxArray.hpp.

static bool MxArray::isNaN ( double  d)
inlinestatic

Determine whether input is NaN (Not-a-Number).

Parameters
ddouble-precision floating-point number
Returns
true if value is NaN, false otherwise.

Definition at line 877 of file MxArray.hpp.

bool MxArray::isNull ( ) const
inline

Determine whether the array is initialized or not.

Returns
true if the internal mxArray pointer is NULL, false otherwise.

Definition at line 606 of file MxArray.hpp.

bool MxArray::isNumeric ( ) const
inline

Determine whether array is numeric.

Returns
true if array is numeric, false otherwise.

Definition at line 695 of file MxArray.hpp.

bool MxArray::isSingle ( ) const
inline

Determine whether array represents data as single-precision, floating-point numbers.

Returns
true if array is of type mxSINGLE_CLASS, false otherwise.

Definition at line 700 of file MxArray.hpp.

bool MxArray::isSparse ( ) const
inline

Determine whether input is sparse array.

Returns
true if array is numeric sparse array, false otherwise.

Definition at line 704 of file MxArray.hpp.

bool MxArray::isStruct ( ) const
inline

Determine whether input is structure array.

Returns
true if array is of type mxSTRUCT_CLASS, false otherwise.

Definition at line 708 of file MxArray.hpp.

bool MxArray::isUint16 ( ) const
inline

Determine whether array represents data as unsigned 16-bit integers.

Returns
true if array is of type mxUINT16_CLASS, false otherwise.

Definition at line 716 of file MxArray.hpp.

bool MxArray::isUint32 ( ) const
inline

Determine whether array represents data as unsigned 32-bit integers.

Returns
true if array is of type mxUINT32_CLASS, false otherwise.

Definition at line 720 of file MxArray.hpp.

bool MxArray::isUint64 ( ) const
inline

Determine whether array represents data as unsigned 64-bit integers.

Returns
true if array is of type mxUINT64_CLASS, false otherwise.

Definition at line 724 of file MxArray.hpp.

bool MxArray::isUint8 ( ) const
inline

Determine whether array represents data as unsigned 8-bit integers.

Returns
true if array is of type mxUINT8_CLASS, false otherwise.

Definition at line 712 of file MxArray.hpp.

static double MxArray::NaN ( )
inlinestatic

Value of NaN (Not-a-Number).

Returns
double-precision value representing NaN.

Definition at line 885 of file MxArray.hpp.

mwSize MxArray::ndims ( ) const
inline

Number of dimensions.

Returns
number of dimension in the array, always >= 2.

Definition at line 550 of file MxArray.hpp.

int MxArray::nfields ( ) const
inline

Number of fields in a struct array.

Returns
number of fields in the structure array.

Definition at line 569 of file MxArray.hpp.

mwSize MxArray::numel ( ) const
inline

Number of elements in an array.

Returns
number of elements in the array

Definition at line 546 of file MxArray.hpp.

mwSize MxArray::nzmax ( ) const
inline

Number of elements in IR, PR, and PI arrays.

Returns
number of elements allocated to hold nonzero entries in the sparse array.

Definition at line 583 of file MxArray.hpp.

MxArray::operator const mxArray * ( ) const
inline

Implicit conversion to const mxArray*.

Returns
const mxArray* pointer.

Definition at line 333 of file MxArray.hpp.

MxArray::operator mxArray * ( ) const
inline

Implicit conversion to mxArray*.

Returns
mxArray* pointer.

Be careful that this internally casts away mxArray* constness.

Definition at line 339 of file MxArray.hpp.

MxArray & MxArray::operator= ( const MxArray rhs)

Assignment operator.

Parameters
rhsReference to another MxArray.
Returns
reference to current MxArray object (for chained calls).

Definition at line 102 of file MxArray.cpp.

mwSize MxArray::rows ( ) const
inline

Number of rows in an array.

Returns
number of rows in the array (first dimension).

Definition at line 558 of file MxArray.hpp.

template<typename T >
void MxArray::set ( mwIndex  index,
const T &  value 
)

Template for numeric array element write accessor.

Parameters
indexlinear index of the array element.
valuevalue to assign to the element at the specified index.

(If the array is a cell array, value type must be convertible to MxArray using an existing constructor.)

In MATLAB, this is equivalent to setting:

arr(index) = value

Example:

MxArray arr(prhs[0]);
arr.set<double>(0, 3.14);

Definition at line 1310 of file MxArray.hpp.

template<typename T >
void MxArray::set ( mwIndex  i,
mwIndex  j,
const T &  value 
)

Template for numeric array element write accessor.

Parameters
iindex of the first dimension of the array element.
jindex of the first dimension of the array element.
valuevalue to assign to the element at the specified index.

In MATLAB, this is equivalent to setting:

arr(i,j) = value

Definition at line 1370 of file MxArray.hpp.

template<typename T >
void MxArray::set ( const std::vector< mwIndex > &  si,
const T &  value 
)

Template for numeric array element write accessor.

Parameters
sivector of subscripts for each dimension of the array.
valuevalue to assign to the element at the specified subscript.

In MATLAB, this is equivalent to setting:

arr(dim1Sub, dim2Sub, ,dim3Sub, ...) = value

Definition at line 1376 of file MxArray.hpp.

template<typename T >
void MxArray::set ( const std::string &  fieldName,
const T &  value,
mwIndex  index = 0 
)

Template for struct array element write accessor.

Parameters
fieldNamename of field in the structure.
valuevalue to assign to the field.
indexlinear index of the struct array element.

The value type must be convertible to MxArray using an existing constructor.

In MATLAB, this is equivalent to setting:

st(index).fieldname = value

Example:

MxArray structArray = MxArray::Struct();
structArray.set<double>("some_field", 3.14);

Definition at line 1382 of file MxArray.hpp.

void MxArray::set ( mwIndex  index,
const MxArray value 
)

Cell array element write accessor.

Parameters
indexlinear index of the cell array element.
valueMxArray to assign to the element at the specified index.

Example:

MxArray cellArray = MxArray::Cell(1,2);
cellArray.set<MxArray>(0, MxArray(3.14));
cellArray.set<MxArray>(1, MxArray(std::string("hello")));

Definition at line 836 of file MxArray.cpp.

static MxArray MxArray::Struct ( const char **  fields = NULL,
int  nfields = 0,
mwSize  m = 1,
mwSize  n = 1 
)
inlinestatic

Create a new struct array.

Parameters
fieldsField names.
nfieldsNumber of fields.
mNumber of rows (size of the first dimension).
nNumber of cols (size of the second dimension).
Returns
MxArray object, a 2D struct array with uninitialized fields.

Example:

const char* fields[] = {"field1", "field2"};
MxArray s = MxArray::Struct(fields, 2);
s.set("field1", 1);
s.set("field2", "field2 value");

Definition at line 312 of file MxArray.hpp.

mwIndex MxArray::subs ( mwIndex  i,
mwIndex  j = 0 
) const

Offset from first element to desired element.

Parameters
iindex of the first dimension of the array.
jindex of the second dimension of the array.
Returns
linear offset of the specified subscript index.

Return the offset (in number of elements) from the beginning of the array to the specified (i,j) subscript.

Definition at line 798 of file MxArray.cpp.

mwIndex MxArray::subs ( const std::vector< mwIndex > &  si) const

Offset from first element to desired element.

Parameters
sivector of subscripts for each dimension of the array.
Returns
linear offset of the specified subscripts.

Return the offset (in number of elements) from the beginning of the array to the specified subscript (si[0], si[1], ..., si[n]).

Definition at line 806 of file MxArray.cpp.

bool MxArray::toBool ( ) const

Convert MxArray to bool.

Returns
bool value.

Definition at line 510 of file MxArray.cpp.

cv::DMatch MxArray::toDMatch ( mwIndex  index = 0) const

Convert MxArray to cv::DMatch.

Parameters
indexlinear index of the struct array element.
Returns
cv::DMatch object.

Definition at line 734 of file MxArray.cpp.

double MxArray::toDouble ( ) const

Convert MxArray to double.

Returns
double value.

Definition at line 496 of file MxArray.cpp.

float MxArray::toFloat ( ) const

Convert MxArray to float.

Returns
float value.

Definition at line 503 of file MxArray.cpp.

int MxArray::toInt ( ) const

Convert MxArray to int.

Returns
int value.

Definition at line 489 of file MxArray.cpp.

cv::KeyPoint MxArray::toKeyPoint ( mwIndex  index = 0) const

Convert MxArray to cv::KeyPoint.

Parameters
indexlinear index of the struct array element.
Returns
cv::KeyPoint object.

Definition at line 722 of file MxArray.cpp.

cv::Mat MxArray::toMat ( int  depth = CV_USRTYPE1,
bool  transpose = true 
) const

Convert MxArray to cv::Mat.

Parameters
depthdepth of cv::Mat. e.g., CV_8U, CV_32F. When CV_USERTYPE1 is specified, depth will be automatically determined from the classid of the MxArray. default: CV_USERTYPE1.
transposeOptional transposition to the return value so that rows and columns of the 2D Mat are mapped to the 2nd and 1st dimensions in MxArray, respectively. This does not apply the N-D array conversion. default true.
Returns
cv::Mat object.

Convert a MxArray object to a cv::Mat object. When the dimensionality of the MxArray is more than 2, the last dimension will be mapped to the channels of the cv::Mat. Also, if the resulting cv::Mat is 2D, the 1st and 2nd dimensions of the MxArray are mapped to rows and columns of the cv::Mat unless transpose flag is false. That is, when MxArray is 3D, (dim 1, dim 2, dim 3) are mapped to (cols, rows, channels) of the cv::Mat by default, whereas if MxArray is more than 4D, (dim 1, dim 2, ..., dim N-1, dim N) are mapped to (dim 2, dim 1, ..., dim N-1, channels) of the cv::Mat, respectively.

Example:

cv::Mat x(MxArray(prhs[0]).toMat());

Definition at line 529 of file MxArray.cpp.

cv::MatND MxArray::toMatND ( int  depth = CV_USRTYPE1,
bool  transpose = true 
) const

Convert MxArray to a single-channel cv::Mat.

Parameters
depthdepth of cv::Mat. e.g., CV_8U, CV_32F. When CV_USERTYPE1 is specified, depth will be automatically determined from the the classid of the MxArray. default: CV_USERTYPE1.
transposeOptional transposition to the return value so that rows and columns of the 2D Mat are mapped to the 2nd and 1st dimensions in MxArray, respectively. This does not apply the N-D array conversion. default true.
Returns
const cv::Mat object.

Convert a MxArray object to a single-channel cv::Mat object. If the MxArray is 2D, the 1st and 2nd dimensions of the MxArray are mapped to rows and columns of the cv::Mat unless transpose flag is false. If the MxArray is more than 3D, the 1st and 2nd dimensions of the MxArray are mapped to 2nd and 1st dimensions of the cv::Mat. That is, when MxArray is 2D, (dim 1, dim 2) are mapped to (cols, rows) of the cv::Mat by default, whereas if MxArray is more than 3D, (dim 1, dim 2, dim 3, ..., dim N) are mapped to (dim 2, dim 1, dim 3, ..., dim N) of the cv::Mat, respectively.

Example:

cv::Mat x(MxArray(prhs[0]).toMatND());

Definition at line 601 of file MxArray.cpp.

template<typename T , int m, int n>
cv::Matx< T, m, n > MxArray::toMatx ( ) const

Convert MxArray to Matx<T,m,n>.

Returns
cv::Matx<T,m,n> value.

Definition at line 1131 of file MxArray.hpp.

cv::Moments MxArray::toMoments ( mwIndex  index = 0) const

Convert MxArray to cv::Moments.

Parameters
indexlinear index of the struct array element.
Returns
cv::Moments object.

Definition at line 705 of file MxArray.cpp.

cv::Point MxArray::toPoint ( ) const
inline

Alias to toPoint_<int>.

Returns
cv::Point object.

Definition at line 511 of file MxArray.hpp.

cv::Point2f MxArray::toPoint2f ( ) const
inline

Alias to toPoint_<float>.

Returns
cv::Point2f object.

Definition at line 515 of file MxArray.hpp.

template<typename T >
cv::Point3_< T > MxArray::toPoint3_ ( ) const

Convert MxArray to Point3_<T>.

Returns
cv::Poin3_<T> value.

Definition at line 1075 of file MxArray.hpp.

cv::Point3f MxArray::toPoint3f ( ) const
inline

Alias to toPoint3_<float>.

Returns
cv::Point3f object.

Definition at line 519 of file MxArray.hpp.

template<typename T >
cv::Point_< T > MxArray::toPoint_ ( ) const

Convert MxArray to Point_<T>.

Returns
cv::Point_<T> value.

Definition at line 1067 of file MxArray.hpp.

cv::Range MxArray::toRange ( ) const

Convert MxArray to cv::Range.

Returns
cv::Range object.

Definition at line 744 of file MxArray.cpp.

cv::Rect MxArray::toRect ( ) const
inline

Alias to toRect_<int>.

Returns
cv::Rect object.

Definition at line 527 of file MxArray.hpp.

template<typename T >
cv::Rect_< T > MxArray::toRect_ ( ) const

Convert MxArray to Rect_<T>.

Returns
cv::Rect_<T> value.

Definition at line 1091 of file MxArray.hpp.

cv::RotatedRect MxArray::toRotatedRect ( mwIndex  index = 0) const

Convert MxArray to cv::RotatedRect.

Parameters
indexlinear index of the struct array element.
Returns
cv::RotatedRect object.

Definition at line 756 of file MxArray.cpp.

cv::Scalar MxArray::toScalar ( ) const
inline

Alias to toScalar_<double>

Returns
cv::Scalar object.

Definition at line 531 of file MxArray.hpp.

template<typename T >
cv::Scalar_< T > MxArray::toScalar_ ( ) const

Convert MxArray to Scalar_<T>.

Returns
cv::Scalar_<T> value.

Definition at line 1099 of file MxArray.hpp.

cv::Size MxArray::toSize ( ) const
inline

Alias to toSize_<int>.

Returns
cv::Size object.

Definition at line 523 of file MxArray.hpp.

template<typename T >
cv::Size_< T > MxArray::toSize_ ( ) const

Convert MxArray to Size_<T>.

Returns
cv::Size_<T> value.

Definition at line 1083 of file MxArray.hpp.

cv::SparseMat MxArray::toSparseMat ( int  depth = CV_USRTYPE1) const

Convert double sparse MxArray to 2D single-channel cv::SparseMat.

Parameters
depthdepth of cv::SparseMat. e.g., CV_32F, CV_64F. When CV_USERTYPE1 is specified, depth will be automatically determined from the the classid of the MxArray (which is double, the only supported type for MATLAB sparse arrays). default: CV_USERTYPE1.
Returns
cv::SparseMat object.

Definition at line 647 of file MxArray.cpp.

std::string MxArray::toString ( ) const

Convert MxArray to std::string.

Returns
std::string value.

Definition at line 517 of file MxArray.cpp.

cv::TermCriteria MxArray::toTermCriteria ( mwIndex  index = 0) const

Convert MxArray to cv::TermCriteria.

Parameters
indexlinear index of the struct array element.
Returns
cv::TermCriteria object.

Definition at line 765 of file MxArray.cpp.

template<typename T , int cn>
cv::Vec< T, cn > MxArray::toVec ( ) const

Convert MxArray to Vec<T,cn>.

Returns
cv::Vec<T,cn> value.

Definition at line 1114 of file MxArray.hpp.

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

Convert MxArray to std::vector<T> of primitive types.

Returns
std::vector<T> value.

The method is intended for conversion to a raw numeric vector such as std::vector<int> or std::vector<double>. Example:

MxArray numArray(prhs[0]);
vector<double> vd = numArray.toVector<double>();

Definition at line 1151 of file MxArray.hpp.

template<typename T >
std::vector< T > MxArray::toVector ( std::const_mem_fun_ref_t< T, MxArray f) const

Convert MxArray to std::vector<T> by a specified conversion method.

Parameters
fmember function of MxArray (e.g., &MxArray::toMat, &MxArray::toInt).
Returns
std::vector<T> value.

The method constructs std::vector<T> by applying conversion method f to each cell array element. This is similar to std::transform function. An example usage is shown below:

MxArray cellArray(prhs[0]);
const_mem_fun_ref_t<Point3i,MxArray> convert(&MxArray::toPoint3_<int>);
vector<Point3i> v = cellArray.toVector(convert);

Definition at line 1239 of file MxArray.hpp.

std::vector< MxArray > MxArray::toVector ( ) const

Convert MxArray to std::vector<MxArray>.

Returns
std::vector<MxArray> value.

Example:

MxArray cellArray(prhs[0]);
vector<MxArray> v = cellArray.toVector<MxArray>();

Definition at line 846 of file MxArray.cpp.

std::vector< std::string > MxArray::toVector ( ) const

Convert MxArray to std::vector<std::string>.

Returns
std::vector<std::string> value.

The input MxArray is expected to be a cell-array of strings, e.g: {'str1', 'str2', ...}, or a single string 'str'.

Example:

MxArray cellArray(prhs[0]);
vector<string> v = cellArray.toVector<string>();

Definition at line 862 of file MxArray.cpp.

std::vector< cv::Mat > MxArray::toVector ( ) const

Convert MxArray to std::vector<cv::Mat>.

Returns
std::vector<cv::Mat> value.

The input MxArray can be either:

  • a cell-array of matrices of length N, e.g: {m1, m2, ...}
  • a single numeric matrix (hence N=1)

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Mat> v = cellArray.toVector<Mat>();

Definition at line 869 of file MxArray.cpp.

std::vector< cv::Point > MxArray::toVector ( ) const

Convert MxArray to std::vector<Point>.

Returns
std::vector<Point> value.

The input MxArray can be either:

  • a cell-array of 2D integer 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,x,...], [y,y,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Point> v = cellArray.toVector<Point>();

Definition at line 880 of file MxArray.cpp.

std::vector< cv::Point2f > MxArray::toVector ( ) const

Convert MxArray to std::vector<Point2f>.

Returns
std::vector<Point2f> value.

The input MxArray can be either:

  • a cell-array of 2D float 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,x,...], [y,y,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Point2f> v = cellArray.toVector<Point2f>();

Definition at line 898 of file MxArray.cpp.

std::vector< cv::Point2d > MxArray::toVector ( ) const

Convert MxArray to std::vector<Point2d>.

Returns
std::vector<Point2d> value.

The input MxArray can be either:

  • a cell-array of 2D double 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,x,...], [y,y,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Point2d> v = cellArray.toVector<Point2d>();

Definition at line 916 of file MxArray.cpp.

std::vector< cv::Point3i > MxArray::toVector ( ) const

Convert MxArray to std::vector<Point3i>.

Returns
std::vector<Point3i> value.

The input MxArray can be either:

  • a cell-array of 3D integer 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,x,...], [y,y,...], [z,z,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Point3i> v = cellArray.toVector<Point3i>();

Definition at line 934 of file MxArray.cpp.

std::vector< cv::Point3f > MxArray::toVector ( ) const

Convert MxArray to std::vector<Point3f>.

Returns
std::vector<Point3f> value.

The input MxArray can be either:

  • a cell-array of 3D float 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,x,...], [y,y,...], [z,z,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Point3f> v = cellArray.toVector<Point3f>();

Definition at line 952 of file MxArray.cpp.

std::vector< cv::Point3d > MxArray::toVector ( ) const

Convert MxArray to std::vector<Point3d>.

Returns
std::vector<Point3d> value.

The input MxArray can be either:

  • a cell-array of 3D double 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,x,...], [y,y,...], [z,z,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Point3d> v = cellArray.toVector<Point3d>();

Definition at line 970 of file MxArray.cpp.

std::vector< cv::Size > MxArray::toVector ( ) const

Convert MxArray to std::vector<Size>.

Returns
std::vector<Size> value.

The input MxArray can be either:

  • 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,w,...], [h,h,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Size> v = cellArray.toVector<Size>();

Definition at line 988 of file MxArray.cpp.

std::vector< cv::Rect > MxArray::toVector ( ) const

Convert MxArray to std::vector<Rect>.

Returns
std::vector<Rect> value.

The input MxArray can be either:

  • 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,x,...], [y,y,...] ,[w,w,...], [h,h,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Rect> v = cellArray.toVector<Rect>();

Definition at line 1005 of file MxArray.cpp.

std::vector< cv::Vec2i > MxArray::toVector ( ) const

Convert MxArray to std::vector<Vec2i>.

Returns
std::vector<Vec2i> value.

The input MxArray can be either:

  • a cell-array of 2-element vectors of length N, e.g: {[v1,v2], [v1,v2], ...}
  • a numeric matrix of size Nx2, Nx1x2, or 1xNx2 in the form: [v1,v2; v1,v2; ...] or cat(3, [v1,v1,...], [v2,v2,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Vec2i> v = cellArray.toVector<Vec2i>();

Definition at line 1022 of file MxArray.cpp.

std::vector< cv::Vec2f > MxArray::toVector ( ) const

Convert MxArray to std::vector<Vec2f>.

Returns
std::vector<Vec2f> value.

The input MxArray can be either:

  • a cell-array of 2-element vectors of length N, e.g: {[v1,v2], [v1,v2], ...}
  • a numeric matrix of size Nx2, Nx1x2, or 1xNx2 in the form: [v1,v2; v1,v2; ...] or cat(3, [v1,v1,...], [v2,v2,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Vec2f> v = cellArray.toVector<Vec2f>();

Definition at line 1040 of file MxArray.cpp.

std::vector< cv::Vec3i > MxArray::toVector ( ) const

Convert MxArray to std::vector<Vec3i>.

Returns
std::vector<Vec3i> value.

The input MxArray can be either:

  • a cell-array of 3-element vectors of length N, e.g: {[v1,v2,v3], [v1,v2,v3], ...}
  • a numeric matrix of size Nx3, Nx1x3, or 1xNx3 in the form: [v1,v2,v3; v1,v2,v3; ...] or cat(3, [v1,v1,...], [v2,v2,...], [v3,v3,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Vec3i> v = cellArray.toVector<Vec3i>();

Definition at line 1058 of file MxArray.cpp.

std::vector< cv::Vec3f > MxArray::toVector ( ) const

Convert MxArray to std::vector<Vec3f>.

Returns
std::vector<Vec3f> value.

The input MxArray can be either:

  • a cell-array of 3-element vectors of length N, e.g: {[v1,v2,v3], [v1,v2,v3], ...}
  • a numeric matrix of size Nx3, Nx1x3, or 1xNx3 in the form: [v1,v2,v3; v1,v2,v3; ...] or cat(3, [v1,v1,...], [v2,v2,...], [v3,v3,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Vec3f> v = cellArray.toVector<Vec3f>();

Definition at line 1076 of file MxArray.cpp.

std::vector< cv::Vec4i > MxArray::toVector ( ) const

Convert MxArray to std::vector<Vec4i>.

Returns
std::vector<Vec4i> value.

The input MxArray can be either:

  • a cell-array of 4-element vectors of length N, e.g: {[v1,v2,v3,v4], [v1,v2,v3,v4], ...}
  • a numeric matrix of size Nx4, Nx1x4, or 1xNx4 in the form: [v1,v2,v3,v4; v1,v2,v3,v4; ...] or cat(3, [v1,v1,...], [v2,v2,...], [v3,v3,...], [v4,v4,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Vec4i> v = cellArray.toVector<Vec4i>();

Definition at line 1094 of file MxArray.cpp.

std::vector< cv::Vec4f > MxArray::toVector ( ) const

Convert MxArray to std::vector<Vec4f>.

Returns
std::vector<Vec4f> value.

The input MxArray can be either:

  • a cell-array of 4-element vectors of length N, e.g: {[v1,v2,v3,v4], [v1,v2,v3,v4], ...}
  • a numeric matrix of size Nx4, Nx1x4, or 1xNx4 in the form: [v1,v2,v3,v4; v1,v2,v3,v4; ...] or cat(3, [v1,v1,...], [v2,v2,...], [v3,v3,...], [v4,v4,...])

where N will be the output vector size.

Example:

MxArray cellArray(prhs[0]);
vector<Vec4f> v = cellArray.toVector<Vec4f>();

Definition at line 1112 of file MxArray.cpp.

std::vector< cv::RotatedRect > MxArray::toVector ( ) const

Convert MxArray to std::vector<cv::RotatedRect>.

Returns
std::vector<cv::RotatedRect> value.

The input MxArray can be either:

  • a cell-array of rotated rectangles (scalar structs) of length N, e.g: {struct('center',[x,y], 'size',[a,b], 'angle',t), ...}
  • a structure-array of length N, in the form: struct('center',{[x,y],...}, 'size',{[a,b],...}, 'angle',{t,...})

where N will be the output vector size.

Example:

MxArray structArray(prhs[0]);
vector<RotatedRect> v = structArray.toVector<RotatedRect>();

Definition at line 1130 of file MxArray.cpp.

std::vector< cv::KeyPoint > MxArray::toVector ( ) const

Convert MxArray to std::vector<cv::KeyPoint>.

Returns
std::vector<cv::KeyPoint> value.

The input MxArray can be either:

  • a cell-array of keypoints (scalar structs) of length N, e.g: {struct('pt',[x,y], 'size',[a,b], 'angle',t), ...}
  • a structure-array of length N, in the form: struct('pt',{[x,y],...}, 'size',{[a,b],...}, 'angle',{t,...})

where N will be the output vector size.

Example:

MxArray structArray(prhs[0]);
vector<KeyPoint> v = structArray.toVector<KeyPoint>();

Definition at line 1148 of file MxArray.cpp.

std::vector< cv::DMatch > MxArray::toVector ( ) const

Convert MxArray to std::vector<cv::DMatch>.

Returns
std::vector<cv::DMatch> value.

The input MxArray can be either:

  • a cell-array of dmatches (scalar structs) of length N, e.g: {struct('queryIdx',i, 'trainIdx',j, 'distance',d), ...}
  • a structure-array of length N, in the form: struct('queryIdx',{i,...}, 'trainIdx',{j,...}, 'distance',{d,...})

where N will be the output vector size.

Example:

MxArray structArray(prhs[0]);
vector<DMatch> v = structArray.toVector<DMatch>();

Definition at line 1166 of file MxArray.cpp.


The documentation for this class was generated from the following files: