OpenPose
1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
|
#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 int size, T *const dataPtr) | |
Array (const std::vector< int > &sizes, T *const dataPtr) | |
Array (const Array< T > &array, const int index, const bool noCopy=false) | |
template<typename T2 > | |
Array (const Array< T2 > &array) | |
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 | reset (const int size, T *const dataPtr) |
void | reset (const std::vector< int > &sizes, T *const dataPtr) |
void | setFrom (const Matrix &cvMat) |
void | setTo (const T value) |
bool | empty () const |
std::vector< int > | getSize () const |
int | getSize (const int index) const |
std::string | printSize () const |
size_t | getNumberDimensions () const |
size_t | getVolume () const |
size_t | getVolume (const int indexA, const int indexB=-1) const |
std::vector< int > | getStride () const |
int | getStride (const int index) const |
T * | getPtr () |
const T * | getConstPtr () const |
T * | getPseudoConstPtr () const |
const Matrix & | getConstCvMat () const |
Matrix & | 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 Mat in OpenCV, Tensor in Torch/TensorFlow or Blob in Caffe. It wraps a Matrix 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. |
op::Array< T >::Array | ( | const Array< T > & | array, |
const int | index, | ||
const bool | noCopy = false |
||
) |
Array constructor.
array | Array<T> with the original data array to slice. |
index | indicates the index of the array to extract. |
noCopy | indicates whether to perform a copy. Copy will never go to undefined behavior, however, if noCopy == true, then: |
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 |
Return a Matrix 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 Matrix 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 |
Analogous to getConstCvMat, but in this case it returns a editable Matrix. Very important: Only allowed functions which do not provoke data reallocation. E.g., resizing functions will not work and they would provoke an undefined behavior and/or execution crashes.
|
inline |
|
inline |
Similar to getConstPtr(), but it allows the data to be edited. This function is only implemented for Pybind11 usage.
|
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 |
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. |
std::vector<int> op::Array< T >::getStride | ( | ) | const |
Return the stride or step size of the array. E.g., given and Array<T> of size 5x3, getStride() would return the following vector: {5x3sizeof(T), 3sizeof(T), sizeof(T)}.
int op::Array< T >::getStride | ( | const int | index | ) | const |
Return the stride or step size of the array at the index-th dimension. E.g., given and Array<T> of size 5x3, getStride(2) would return sizeof(T).
|
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 = -1 |
||
) | 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.
indexA | Dimension where to start. |
indexB | Dimension where to stop. If indexB == -1, then it will take up to the last dimension. |
Move assignment. Similar to Array<T>(Array<T>&& array).
array | Array to be moved. |
Copy assignment. Similar to Array<T>(const Array<T>& array).
array | Array to be copied. |
|
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 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 int | size, |
T *const | dataPtr | ||
) |
Data allocation function. Equivalent to default constructor, but it does not allocate memory, but rather use dataPtr.
size | Integer with the number of T element to be allocated. E.g., size = 5 is internally similar to new T[5] . |
dataPtr | Pointer to the memory to be used by 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 >::reset | ( | const std::vector< int > & | sizes, |
T *const | dataPtr | ||
) |
Data allocation function. Equivalent to default constructor, but it does not allocate memory, but rather use dataPtr.
sizes | Vector with the size of each dimension. E.g., size = {3, 5, 2} is internally similar to: new T[3*5*2] . |
dataPtr | Pointer to the memory to be used by the Array. |
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 >::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