OpenCV  3.0.0
Open Source Computer Vision
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

matlab::MxArray::MxArray ( )
inline

default constructor

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

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

destructor

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

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

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 
)
inline

explicit typed constructor

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

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

size_t matlab::MxArray::channels ( ) const
inline
std::string matlab::MxArray::className ( ) const
inline
size_t matlab::MxArray::cols ( ) const
inline
bool matlab::MxArray::empty ( ) const
inline
MxArray matlab::MxArray::field ( const std::string &  name)
inline
mxClassID matlab::MxArray::ID ( ) const
inline
template<typename Scalar >
Scalar* matlab::MxArray::imag ( )
inline
template<typename Scalar >
const Scalar* matlab::MxArray::imag ( ) const
inline
bool matlab::MxArray::isCell ( ) const
inline
bool matlab::MxArray::isClass ( const std::string &  name) const
inline
bool matlab::MxArray::isComplex ( ) const
inline
bool matlab::MxArray::isLogical ( ) const
inline
bool matlab::MxArray::isNumeric ( ) const
inline
bool matlab::MxArray::isString ( ) const
inline
bool matlab::MxArray::isStructure ( ) const
inline
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

MxArray& matlab::MxArray::operator= ( const mxArray *  ptr)
inline
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

template<typename Scalar >
Scalar* matlab::MxArray::real ( )
inline
template<typename Scalar >
const Scalar* matlab::MxArray::real ( ) const
inline
mxArray* matlab::MxArray::releaseOwnership ( )
inline
size_t matlab::MxArray::rows ( ) const
inline
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

template<typename Scalar >
Scalar matlab::MxArray::scalar ( ) const
inline
size_t matlab::MxArray::size ( ) const
inline
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

std::string matlab::MxArray::toString ( ) const
inline
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

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: