OpenCV
3.2.0
Open Source Computer Vision
|
A thin wrapper around Matlab's mxArray types. More...
#include "mxarray.hpp"
Public Member Functions | |
MxArray () | |
default constructor More... | |
MxArray (const mxArray *ptr) | |
inheriting constructor More... | |
MxArray (size_t m, size_t n, size_t k, mxClassID id, mxComplexity com=matlab::Traits<>::Real) | |
explicit typed constructor More... | |
MxArray (const MxArray &other) | |
copy constructor More... | |
virtual | ~MxArray () |
destructor More... | |
size_t | channels () const |
std::string | className () const |
size_t | cols () const |
bool | empty () const |
MxArray | field (const std::string &name) |
mxClassID | ID () const |
template<typename Scalar > | |
Scalar * | imag () |
template<typename Scalar > | |
const Scalar * | imag () const |
bool | isCell () const |
bool | isClass (const std::string &name) const |
bool | isComplex () const |
bool | isLogical () const |
bool | isNumeric () const |
bool | isString () const |
bool | isStructure () const |
MxArray & | operator= (const mxArray *ptr) |
MxArray & | operator= (MxArray other) |
copy-and-swap assignment More... | |
template<typename Scalar > | |
Scalar * | real () |
template<typename Scalar > | |
const Scalar * | real () const |
mxArray * | releaseOwnership () |
size_t | rows () const |
template<typename Scalar > | |
Scalar | scalar () const |
size_t | size () const |
std::string | toString () const |
Static Public Member Functions | |
template<typename Scalar > | |
static MxArray | Matrix (size_t m, size_t n) |
explicit matrix constructor More... | |
template<typename ScalarType > | |
static MxArray | Scalar (ScalarType value=0) |
explicit scalar constructor More... | |
template<typename Scalar > | |
static MxArray | Tensor (size_t m, size_t n, size_t k=1) |
explicit tensor constructor More... | |
template<typename Scalar > | |
static MxArray | Vector (size_t m) |
explicit vector constructor More... | |
Friends | |
void | swap (MxArray &first, MxArray &second) |
swap all members of this and other More... | |
A thin wrapper around Matlab's mxArray types.
MxArray provides a thin object oriented wrapper around Matlab's native mxArray type which exposes most of the functionality of the Matlab interface, but in a more C++ manner. MxArray objects are scoped, so you can freely create and destroy them without worrying about memory management. If you wish to pass the underlying mxArray* representation back to Matlab as an lvalue, see the releaseOwnership() method
MxArrays can be directly converted into OpenCV mat objects and std::string objects, since there is a natural mapping between these types. More complex types are mapped through the Bridge which does custom conversions such as MxArray –> cv::Keypoints, etc
matlab::MxArray::MxArray | ( | ) |
default constructor
Construct a valid 0x0 matrix (so all other methods do not need validity checks)
|
virtual |
destructor
The destructor deallocates any data allocated by mxCreate* methods only if the object is owned
matlab::MxArray::MxArray | ( | const mxArray * | ptr | ) |
inheriting constructor
Inherit an mxArray from Matlab. Don't claim ownership of the array, just encapsulate it
matlab::MxArray::MxArray | ( | size_t | m, |
size_t | n, | ||
size_t | k, | ||
mxClassID | id, | ||
mxComplexity | com = matlab::Traits<>::Real |
||
) |
explicit typed constructor
This constructor explicitly creates an MxArray of the given size and type.
matlab::MxArray::MxArray | ( | const MxArray & | other | ) |
copy constructor
All copies are deep copies. If you have a C++11 compatible compiler, prefer move construction to copy construction
size_t matlab::MxArray::channels | ( | ) | const |
std::string matlab::MxArray::className | ( | ) | const |
size_t matlab::MxArray::cols | ( | ) | const |
bool matlab::MxArray::empty | ( | ) | const |
MxArray matlab::MxArray::field | ( | const std::string & | name | ) |
mxClassID matlab::MxArray::ID | ( | ) | const |
Scalar* matlab::MxArray::imag | ( | ) |
const Scalar* matlab::MxArray::imag | ( | ) | const |
bool matlab::MxArray::isCell | ( | ) | const |
bool matlab::MxArray::isClass | ( | const std::string & | name | ) | const |
bool matlab::MxArray::isComplex | ( | ) | const |
bool matlab::MxArray::isLogical | ( | ) | const |
bool matlab::MxArray::isNumeric | ( | ) | const |
bool matlab::MxArray::isString | ( | ) | const |
bool matlab::MxArray::isStructure | ( | ) | const |
explicit matrix constructor
Explicitly construct a matrix of given size and type. Since constructors cannot be explicitly templated, this is a static factory method
MxArray& matlab::MxArray::operator= | ( | const mxArray * | ptr | ) |
copy-and-swap assignment
This assignment operator uses the copy and swap idiom to provide a strong exception guarantee when swapping two objects.
Note in particular that the other MxArray is passed by value, thus invoking the copy constructor which performs a deep copy of the input. The members of this and other are then swapped
Scalar* matlab::MxArray::real | ( | ) |
const Scalar* matlab::MxArray::real | ( | ) | const |
mxArray* matlab::MxArray::releaseOwnership | ( | ) |
size_t matlab::MxArray::rows | ( | ) | const |
|
static |
explicit scalar constructor
Explicitly construct a scalar of given type. Since constructors cannot be explicitly templated, this is a static factory method
Scalar matlab::MxArray::scalar | ( | ) | const |
size_t matlab::MxArray::size | ( | ) | const |
|
static |
explicit tensor constructor
Explicitly construct a tensor of given size and type. Since constructors cannot be explicitly templated, this is a static factory method
std::string matlab::MxArray::toString | ( | ) | const |
explicit vector constructor
Explicitly construct a vector of given size and type. Since constructors cannot be explicitly templated, this is a static factory method
swap all members of this and other
the swap method is used by the assignment and move constructors to swap the members of two MxArrays, leaving both in destructible states