OpenCV  3.4.1
Open Source Computer Vision
Public Member Functions | Static Public Member Functions | Friends | List of all members
matlab::MxArray Class Reference

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 >
Scalarimag ()
 
template<typename Scalar >
const Scalarimag () 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
 
MxArrayoperator= (const mxArray *ptr)
 
MxArrayoperator= (MxArray other)
 copy-and-swap assignment More...
 
template<typename Scalar >
Scalarreal ()
 
template<typename Scalar >
const Scalarreal () 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...
 

Detailed Description

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

Constructor & Destructor Documentation

§ MxArray() [1/4]

matlab::MxArray::MxArray ( )
inline

default constructor

Construct a valid 0x0 matrix (so all other methods do not need validity checks)

§ ~MxArray()

virtual matlab::MxArray::~MxArray ( )
inlinevirtual

destructor

The destructor deallocates any data allocated by mxCreate* methods only if the object is owned

§ MxArray() [2/4]

matlab::MxArray::MxArray ( const mxArray *  ptr)
inline

inheriting constructor

Inherit an mxArray from Matlab. Don't claim ownership of the array, just encapsulate it

§ MxArray() [3/4]

matlab::MxArray::MxArray ( size_t  m,
size_t  n,
size_t  k,
mxClassID  id,
mxComplexity  com = matlab::Traits<>::Real 
)
inline

explicit typed constructor

This constructor explicitly creates an MxArray of the given size and type.

§ MxArray() [4/4]

matlab::MxArray::MxArray ( const MxArray other)
inline

copy constructor

All copies are deep copies. If you have a C++11 compatible compiler, prefer move construction to copy construction

Member Function Documentation

§ channels()

size_t matlab::MxArray::channels ( ) const
inline

§ className()

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

§ cols()

size_t matlab::MxArray::cols ( ) const
inline

§ empty()

bool matlab::MxArray::empty ( ) const
inline

§ field()

MxArray matlab::MxArray::field ( const std::string &  name)
inline

§ ID()

mxClassID matlab::MxArray::ID ( ) const
inline

§ imag() [1/2]

template<typename Scalar >
Scalar* matlab::MxArray::imag ( )
inline

§ imag() [2/2]

template<typename Scalar >
const Scalar* matlab::MxArray::imag ( ) const
inline

§ isCell()

bool matlab::MxArray::isCell ( ) const
inline

§ isClass()

bool matlab::MxArray::isClass ( const std::string &  name) const
inline

§ isComplex()

bool matlab::MxArray::isComplex ( ) const
inline

§ isLogical()

bool matlab::MxArray::isLogical ( ) const
inline

§ isNumeric()

bool matlab::MxArray::isNumeric ( ) const
inline

§ isString()

bool matlab::MxArray::isString ( ) const
inline

§ isStructure()

bool matlab::MxArray::isStructure ( ) const
inline

§ Matrix()

template<typename Scalar >
static MxArray matlab::MxArray::Matrix ( size_t  m,
size_t  n 
)
inlinestatic

explicit matrix constructor

Explicitly construct a matrix of given size and type. Since constructors cannot be explicitly templated, this is a static factory method

§ operator=() [1/2]

MxArray& matlab::MxArray::operator= ( const mxArray *  ptr)
inline

§ operator=() [2/2]

MxArray& matlab::MxArray::operator= ( MxArray  other)
inline

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

§ real() [1/2]

template<typename Scalar >
Scalar* matlab::MxArray::real ( )
inline

§ real() [2/2]

template<typename Scalar >
const Scalar* matlab::MxArray::real ( ) const
inline

§ releaseOwnership()

mxArray* matlab::MxArray::releaseOwnership ( )
inline

§ rows()

size_t matlab::MxArray::rows ( ) const
inline

§ Scalar()

template<typename ScalarType >
static MxArray matlab::MxArray::Scalar ( ScalarType  value = 0)
inlinestatic

explicit scalar constructor

Explicitly construct a scalar of given type. Since constructors cannot be explicitly templated, this is a static factory method

§ scalar()

template<typename Scalar >
Scalar matlab::MxArray::scalar ( ) const
inline

§ size()

size_t matlab::MxArray::size ( ) const
inline

§ Tensor()

template<typename Scalar >
static MxArray matlab::MxArray::Tensor ( size_t  m,
size_t  n,
size_t  k = 1 
)
inlinestatic

explicit tensor constructor

Explicitly construct a tensor of given size and type. Since constructors cannot be explicitly templated, this is a static factory method

§ toString()

std::string matlab::MxArray::toString ( ) const
inline

§ Vector()

template<typename Scalar >
static MxArray matlab::MxArray::Vector ( size_t  m)
inlinestatic

explicit vector constructor

Explicitly construct a vector of given size and type. Since constructors cannot be explicitly templated, this is a static factory method

Friends And Related Function Documentation

§ swap

void swap ( MxArray first,
MxArray second 
)
friend

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


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