Open3D (C++ API)
0.18.0+252c867
|
#include <Messages.h>
Public Member Functions | |
template<class T > | |
const T * | Ptr () const |
bool | CheckRank (const std::vector< int > &expected_ranks, std::string &errstr) const |
bool | CheckRank (const std::vector< int > &expected_ranks) const |
bool | CheckShape (const std::vector< int64_t > &expected_shape, std::string &errstr) const |
bool | CheckShape (const std::vector< int64_t > &expected_shape) const |
bool | CheckNonEmpty (std::string &errstr) const |
bool | CheckNonEmpty () const |
bool | CheckType (const std::vector< std::string > &expected_types, std::string &errstr) const |
bool | CheckType (const std::vector< std::string > &expected_types) const |
MSGPACK_DEFINE_MAP (type, shape, data) | |
Static Public Member Functions | |
static std::string | MsgId () |
template<class T > | |
static Array | FromPtr (const T *const ptr, const std::vector< int64_t > &shape) |
static Array | FromTensor (const core::Tensor &tensor) |
Data Fields | |
core::Tensor | tensor_ |
std::string | type |
std::vector< int64_t > | shape |
msgpack::type::raw_ref | data |
Array structure inspired by msgpack_numpy but not directly compatible because they use bin-type for the map keys and we must use string. This structure does not have ownership of the data.
The following code can be used in python to create a compatible dict
def numpy_to_Array(arr): if isinstance(arr, np.ndarray): return {'type': arr.dtype.str, 'shape': arr.shape, 'data': arr.tobytes()} raise Exception('object is not a numpy array')
This codes converts the dict back to numpy.ndarray
def Array_to_numpy(dic): return np.frombuffer(dic['data'], dtype=np.dtype(dic['type'])).reshape(dic['shape'])
|
inline |
|
inline |
Checks for a non empty array. Returns false if the array is empty and appends an error description to errstr.
|
inline |
|
inline |
Checks the rank of the shape. Returns false on mismatch and appends an error description to errstr.
|
inline |
|
inline |
Checks the shape against the expected shape. Use -1 in the expected shape to allow arbitrary values. Returns false on mismatch and appends an error description to errstr.
|
inline |
|
inline |
Checks the data type of the array. Returns false if the type is not in the list of expected types and appends an error description to errstr.
|
inlinestatic |
|
inlinestatic |
Creates an Array from a Tensor. This will copy the tensor to contiguous CPU memory if necessary and the returned array will keep a reference.
|
inlinestatic |
|
inline |
msgpack::type::raw_ref open3d::io::rpc::messages::Array::data |
std::vector<int64_t> open3d::io::rpc::messages::Array::shape |
core::Tensor open3d::io::rpc::messages::Array::tensor_ |
std::string open3d::io::rpc::messages::Array::type |