 |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Go to the documentation of this file.
11 #include <unordered_map>
12 #include <unordered_set>
31 class TensorMap :
public std::unordered_map<std::string, core::Tensor> {
35 :
std::unordered_map<
std::string,
core::Tensor>(),
36 primary_key_(primary_key) {
37 AssertPrimaryKeyInMapOrEmpty();
38 AssertNoReservedKeys();
48 template <
class InputIt>
49 TensorMap(
const std::string& primary_key, InputIt first, InputIt last)
50 :
std::unordered_map<
std::string,
core::Tensor>(first, last),
51 primary_key_(primary_key) {
52 AssertPrimaryKeyInMapOrEmpty();
53 AssertNoReservedKeys();
57 const std::unordered_map<std::string, core::Tensor>& tensor_map)
58 :
TensorMap(primary_key, tensor_map.begin(), tensor_map.end()) {
59 AssertPrimaryKeyInMapOrEmpty();
60 AssertNoReservedKeys();
64 std::initializer_list<value_type> init)
65 :
std::unordered_map<
std::string,
core::Tensor>(init),
66 primary_key_(primary_key) {
67 AssertPrimaryKeyInMapOrEmpty();
68 AssertNoReservedKeys();
73 :
std::unordered_map<
std::string,
core::Tensor>(other),
74 primary_key_(other.primary_key_) {
75 AssertPrimaryKeyInMapOrEmpty();
76 AssertNoReservedKeys();
81 :
std::unordered_map<
std::string,
core::Tensor>(other),
82 primary_key_(other.primary_key_) {
83 AssertPrimaryKeyInMapOrEmpty();
84 AssertNoReservedKeys();
92 std::size_t
Erase(
const std::string key) {
93 if (key == primary_key_) {
99 return this->erase(key);
102 std::pair<iterator, bool>
insert(
const value_type& value) {
106 return std::unordered_map<std::string, core::Tensor>::insert(value);
110 std::pair<iterator, bool>
insert(P&& value) {
114 return std::unordered_map<std::string, core::Tensor>::insert(
115 std::forward<P>(value));
118 iterator
insert(const_iterator hint,
const value_type& value) {
122 return std::unordered_map<std::string, core::Tensor>::insert(hint,
127 iterator
insert(const_iterator hint, P&& value) {
131 return std::unordered_map<std::string, core::Tensor>::insert(
132 hint, std::forward<P>(value));
135 template <
class InputIt>
136 void insert(InputIt first, InputIt last) {
137 for (
auto it = first; it != last; ++it) {
142 std::unordered_map<std::string, core::Tensor>::insert(first, last);
145 void insert(std::initializer_list<value_type> ilist) {
146 for (
auto it = ilist.begin(); it != ilist.end(); ++it) {
151 std::unordered_map<std::string, core::Tensor>::insert(ilist);
163 std::unordered_set<std::string> keys;
164 for (
const auto& item : *
this) {
165 keys.insert(item.first);
198 void AssertPrimaryKeyInMapOrEmpty()
const;
202 void AssertNoReservedKeys()
const;
205 int64_t GetPrimarySize()
const {
return at(primary_key_).GetLength(); }
209 return at(primary_key_).GetDevice();
213 std::string primary_key_;
static RGBDImagePyramid FilterPyramid(const RGBDImagePyramid &rgbd_image_pyramid, Image::FilterType type)
Definition: RGBDImage.cpp:33
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
Definition: TensorMap.h:31
Dtype GetDtype() const
Definition: Tensor.h:1164
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
void insert(std::initializer_list< value_type > ilist)
Definition: TensorMap.h:145
SizeVector GetShape() const
Definition: Tensor.h:1127
FilterType
Specifies the Image filter type.
Definition: Image.h:52
Image depth_
The depth image.
Definition: RGBDImage.h:106
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:181
Image depth_
The depth image.
Definition: RGBDImage.h:137
TensorMap(const std::string &primary_key, std::initializer_list< value_type > init)
Definition: TensorMap.h:63
bool IsEmpty() const override
Is any data stored?
Definition: RGBDImage.cpp:20
TensorMap()
Definition: TensorMap.h:44
std::string GetPrimaryKey() const
Returns the primary key of the TensorMap.
Definition: TensorMap.h:159
Bounding box structure.
Definition: ecvBBox.h:25
TensorMap(const TensorMap &other)
Copy constructor performs a "shallow" copy of the Tensors.
Definition: TensorMap.h:72
std::vector< std::shared_ptr< Image > > ImagePyramid
Typedef and functions for ImagePyramid.
Definition: Image.h:24
int64_t GetRows() const
Get the number of rows of the image.
Definition: Image.h:84
RGBDImagePyramid CreatePyramid(size_t num_of_levels, bool with_gaussian_filter_for_color=true, bool with_gaussian_filter_for_depth=false) const
Definition: RGBDImage.cpp:50
iterator insert(const_iterator hint, const value_type &value)
Definition: TensorMap.h:118
std::pair< iterator, bool > insert(const value_type &value)
Definition: TensorMap.h:102
std::vector< std::shared_ptr< RGBDImage > > RGBDImagePyramid
Typedef and functions for RGBDImagePyramid.
Definition: RGBDImage.h:16
core::Device GetDevice() const override
Get device of the image.
Definition: Image.h:96
RGBDImage(const char *name="RGBD_Image")
Default Constructor.
Definition: RGBDImage.h:30
TensorMap Contiguous() const
Definition: TensorMap.cpp:74
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition: Device.cpp:89
core::Dtype GetDtype() const
Get dtype of the image.
Definition: Image.h:93
TensorMap(const std::string &primary_key, const std::unordered_map< std::string, core::Tensor > &tensor_map)
Definition: TensorMap.h:56
int size
Definition: FileIOFactory.cpp:130
TensorMap(const std::string &primary_key, InputIt first, InputIt last)
Definition: TensorMap.h:49
bool Contains(const std::string &key) const
Definition: TensorMap.h:187
Rgb at(size_t color_id)
Definition: ecvColorTypes.cpp:77
TensorMap(const std::string &primary_key)
Create empty TensorMap and set primary key.
Definition: TensorMap.h:34
bool IsContiguous() const
Definition: TensorMap.cpp:65
Image & Clear() override
Clear image contents by resetting the rows and cols to 0, while keeping channels, dtype and device un...
Definition: Image.h:65
std::string ToString() const
Definition: SizeVector.cpp:132
int height_
Height of the image.
Definition: Image.h:221
std::pair< iterator, bool > insert(P &&value)
Definition: TensorMap.h:110
void AssertSizeSynchronized() const
Assert IsSizeSynchronized().
Definition: TensorMap.cpp:48
std::unordered_set< std::string > GetKeySet() const
Returns a set with all keys.
Definition: TensorMap.h:162
Image & Clear()
Definition: Image.cpp:30
RGBDImage & Clear() override
Clear stored data.
Definition: RGBDImage.cpp:14
std::string ToString() const
Definition: Dtype.h:65
Device GetDevice() const override
Definition: Tensor.cpp:1435
int64_t GetCols() const
Get the number of columns of the image.
Definition: Image.h:87
int width_
Width of the image.
Definition: Image.h:219
ImagePyramid CreatePyramid(size_t num_of_levels, bool with_gaussian_filter=true) const
Function to create image pyramid.
Definition: ImageFactory.cpp:129
virtual ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
Definition: RGBDImage.cpp:21
#define LogError(...)
Definition: Logging.h:60
int count
Definition: FileIOFactory.cpp:132
virtual ccBBox GetAxisAlignedBoundingBox() const
Returns an axis-aligned bounding box of the geometry.
Definition: ecvHObject.cpp:447
bool IsSizeSynchronized() const
Returns true if all tensors in the map have the same size.
Definition: TensorMap.cpp:21
std::size_t Erase(const std::string key)
Erase elements for the TensorMap by key value, if the key exists. If the key does not exists,...
Definition: TensorMap.h:92
#define LogWarning(...)
Definition: Logging.h:72
Image color_
The color image.
Definition: RGBDImage.h:104
iterator insert(const_iterator hint, P &&value)
Definition: TensorMap.h:127
bool IsEmpty() const override
Returns true if rows * cols * channels == 0.
Definition: Image.h:71
int64_t GetChannels() const
Get the number of channels of the image.
Definition: Image.h:90
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:27
std::string ToString() const
Print the TensorMap to string.
Definition: TensorMap.cpp:135
RGBDImage & Clear()
Definition: RGBDImage.cpp:15
virtual Eigen::Vector2d GetMax2DBound() const override
Definition: RGBDImage.cpp:29
TensorMap & operator=(const TensorMap &)=default
virtual Eigen::Vector2d GetMin2DBound() const override
Definition: RGBDImage.cpp:25
static std::unordered_set< std::string > GetReservedKeys()
Get reserved keys for the map. A map cannot contain any of these keys.
Definition: TensorMap.cpp:83
std::string ToString() const
Text description.
Definition: RGBDImage.cpp:22
void insert(InputIt first, InputIt last)
Definition: TensorMap.h:136
Image color_
The color image.
Definition: RGBDImage.h:135
bool AreAligned() const
Are the depth and color images aligned (same viewpoint and resolution)?
Definition: RGBDImage.h:65
char type
Definition: FileIOFactory.cpp:131
RGBDImage A pair of color and depth images.
Definition: RGBDImage.h:21
TensorMap(TensorMap &&other)
Move constructor performs a "shallow" copy of the Tensors.
Definition: TensorMap.h:80