OpenPose
1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
|
#include <array.hpp>
Public Member Functions | |
Array (const int size) | |
Array (const std::vector< int > &sizes={}) | |
Array (const int size, const T value) | |
Array (const std::vector< int > &sizes, const T value) | |
Array (const Array< T > &array) | |
Array< T > & | operator= (const Array< T > &array) |
Array (Array< T > &&array) | |
Array< T > & | operator= (Array< T > &&array) |
Array< T > | clone () const |
void | reset (const int size) |
void | reset (const std::vector< int > &sizes={}) |
void | reset (const int size, const T value) |
void | reset (const std::vector< int > &sizes, const T value) |
void | setFrom (const cv::Mat &cvMat) |
void | setTo (const T value) |
bool | empty () const |
std::vector< int > | getSize () const |
std::string | printSize () const |
int | getSize (const int index) const |
size_t | getNumberDimensions () const |
size_t | getVolume () const |
size_t | getVolume (const int indexA, const int indexB) const |
T * | getPtr () |
const T * | getConstPtr () const |
const cv::Mat & | getConstCvMat () const |
cv::Mat & | getCvMat () |
T & | operator[] (const int index) |
const T & | operator[] (const int index) const |
T & | operator[] (const std::vector< int > &indexes) |
const T & | operator[] (const std::vector< int > &indexes) const |
T & | at (const int index) |
const T & | at (const int index) const |
T & | at (const std::vector< int > &indexes) |
const T & | at (const std::vector< int > &indexes) const |
const std::string | toString () const |
Array<T>: The OpenPose Basic Raw Data Container This template class implements a multidimensional data array. It is our basic data container, analogous to cv::Mat in OpenCV, Tensor in Torch/TensorFlow or Blob in Caffe. It wraps a cv::Mat and a std::shared_ptr, both of them pointing to the same raw data. I.e. they both share the same memory, so we can read and modify this data in both formats with no performance impact. Hence, it keeps high performance while adding high-level functions.
Array constructor. Equivalent to default constructor + reset(const int size).
size | Integer with the number of T element to be allocated. E.g. size = 5 is internally similar to new T[5] . |
Array constructor. Equivalent to default constructor + reset(const std::vector<int>& size = {}).
sizes | Vector with the size of each dimension. E.g. size = {3, 5, 2} is internally similar to new T[3*5*2] . |
Array constructor. Equivalent to default constructor + reset(const int size, const T value).
size | Integer with the number of T element to be allocated. E.g. size = 5 is internally similar to new T[5] . |
value | Initial value for each component of the Array. |
Array constructor. Equivalent to default constructor + reset(const std::vector<int>& size, const T value).
sizes | Vector with the size of each dimension. E.g. size = {3, 5, 2} is internally similar to: new T[3*5*2] . |
value | Initial value for each component of the Array. |
Copy constructor. It performs fast copy
: For performance purpose, copying a Array<T> or Datum or cv::Mat just copies the reference, it still shares the same internal data. Modifying the copied element will modify the original one. Use clone() for a slower but real copy, similarly to cv::Mat and Array<T>.
array | Array to be copied. |
|
inline |
at() function Same functionality as operator[](const int index), but it always check whether the indexes are within the data bounds. Otherwise, it will throw an error.
index | The desired memory location. |
|
inline |
at() function Same functionality as operator[](const int index) const, but it always check whether the indexes are within the data bounds. Otherwise, it will throw an error.
index | The desired memory location. |
|
inline |
at() function Same functionality as operator[](const std::vector<int>& indexes), but it always check whether the indexes are within the data bounds. Otherwise, it will throw an error.
indexes | Vector with the desired memory location. |
|
inline |
at() function Same functionality as operator[](const std::vector<int>& indexes) const, but it always check whether the indexes are within the data bounds. Otherwise, it will throw an error.
indexes | Vector with the desired memory location. |
Clone function. Similar to cv::Mat::clone and Datum::clone. It performs a real but slow copy of the data, i.e., even if the copied element is modified, the original one is not.
|
inline |
Check whether memory has been allocated.
const cv::Mat& op::Array< T >::getConstCvMat | ( | ) | const |
Return a cv::Mat wrapper to the data. It forbids the data to be modified. OpenCV only admits unsigned char, signed char, int, float & double. If the T class is not supported by OpenCV, it will throw an error. Note: Array<T> does not return an editable cv::Mat because some OpenCV functions reallocate memory and it would not longer point to the Array<T> instance. If you want to perform some OpenCV operation on the Array data, you can use: editedCvMat = array.getConstCvMat().clone(); // modify data array.setFrom(editedCvMat)
|
inline |
Similar to getPtr(), but it forbids the data to be edited.
cv::Mat& op::Array< T >::getCvMat | ( | ) |
Analogous to getConstCvMat, but in this case it returns a editable cv::Mat. Very important: Only allowed functions which do not provoke data reallocation. E.g. resizing functions will not work and they would provoke an undefined behaviour and/or execution crashes.
|
inline |
Return the total number of dimensions, equivalent to getSize().size().
|
inline |
Return a raw pointer to the data. Similar to: std::shared_ptr::get(). Note: if you modify the pointer data, you will directly modify it in the Array<T> instance too. If you know you do not want to modify the data, then use getConstPtr() instead.
|
inline |
Return a vector with the size of each dimension allocated.
int op::Array< T >::getSize | ( | const int | index | ) | const |
Return a vector with the size of the desired dimension.
index | Dimension to check its size. |
|
inline |
Return the total number of elements allocated, equivalent to multiply all the components from getSize(). E.g. for a Array<T> of size = {2,5,3}, the volume or total number of elements is: 2x5x3 = 30.
size_t op::Array< T >::getVolume | ( | const int | indexA, |
const int | indexB | ||
) | const |
Similar to getVolume(), but in this case it just returns the volume between the desired dimensions. E.g. for a Array<T> of size = {2,5,3}, the volume or total number of elements for getVolume(1,2) is 5x3 = 15.
Copy assignment. Similar to Array<T>(const Array<T>& array).
array | Array to be copied. |
Move assignment. Similar to Array<T>(Array<T>&& array).
array | Array to be moved. |
|
inline |
[] operator Similar to the [] operator for raw pointer data. If debug mode is enabled, then it will check that the desired index is in the data range, and it will throw an exception otherwise (similar to the at operator).
index | The desired memory location. |
|
inline |
[] operator Same functionality as operator[](const int index), but it forbids modifying the value. Otherwise, const functions would not be able to call the [] operator.
index | The desired memory location. |
|
inline |
[] operator Same functionality as operator[](const int index), but it lets the user introduce the multi-dimensional index. E.g. given a (10 x 10 x 10) array, array[11] is equivalent to array[{1,1,0}]
indexes | Vector with the desired memory location. |
|
inline |
[] operator Same functionality as operator[](const std::vector<int>& indexes), but it forbids modifying the value. Otherwise, const functions would not be able to call the [] operator.
indexes | Vector with the desired memory location. |
std::string op::Array< T >::printSize | ( | ) | const |
Return a string with the size of each dimension allocated.
void op::Array< T >::reset | ( | const int | size | ) |
Data allocation function. It allocates the required space for the memory (it does not initialize that memory).
size | Integer with the number of T element to be allocated. E.g. size = 5 is internally similar to new T[5] . |
void op::Array< T >::reset | ( | const std::vector< int > & | sizes = {} | ) |
Data allocation function. Similar to reset(const int size), but it allocates a multi-dimensional array of dimensions each of the values of the argument.
sizes | Vector with the size of each dimension. E.g. size = {3, 5, 2} is internally similar to new T[3*5*2] . |
void op::Array< T >::reset | ( | const int | size, |
const T | value | ||
) |
Data allocation function. Similar to reset(const int size), but initializing the data to the value specified by the second argument.
size | Integer with the number of T element to be allocated. E.g. size = 5 is internally similar to new T[5] . |
value | Initial value for each component of the Array. |
void op::Array< T >::reset | ( | const std::vector< int > & | sizes, |
const T | value | ||
) |
Data allocation function. Similar to reset(const std::vector<int>& size), but initializing the data to the value specified by the second argument.
sizes | Vector with the size of each dimension. E.g. size = {3, 5, 2} is internally similar to new T[3*5*2] . |
value | Initial value for each component of the Array. |
void op::Array< T >::setFrom | ( | const cv::Mat & | cvMat | ) |
Data allocation function. It internally allocates memory and copies the data of the argument to the Array allocated memory.
cvMat | cv::Mat to be copied. |
void op::Array< T >::setTo | ( | const T | value | ) |
Data allocation function. It internally assigns all the allocated memory to the value indicated by the argument.
value | Value for each component of the Array. |
const std::string op::Array< T >::toString | ( | ) | const |
It returns a string with the whole array data. Useful for debugging. The format is: values separated by a space, and a enter for each dimension. E.g.: For the Array{2, 2, 3}, it will print: Array<T>::toString(): x1 x2 x3 x4 x5 x6
x7 x8 x9 x10 x11 x12