HDF5Kernel.hpp
Go to the documentation of this file.
1 #ifndef HDF5KERNEL_HPP
2 #define HDF5KERNEL_HPP
3 
4 #include <hdf5_hl.h>
5 #include <highfive/H5DataSet.hpp>
7 #include <highfive/H5File.hpp>
8 
9 #include "lvr2/types/Channel.hpp"
14 
15 #include <type_traits>
16 #include <tuple>
17 namespace lvr2
18 {
19 class HDF5Kernel : public FileKernel
20 {
21 public:
22 
23  HDF5Kernel() = delete;
24  HDF5Kernel(const std::string& hdf5file);
26 
27  virtual void saveMeshBuffer(
28  const std::string& group,
29  const std::string& container,
30  const MeshBufferPtr& buffer) const;
31 
32  virtual void savePointBuffer(
33  const std::string& group,
34  const std::string& container,
35  const PointBufferPtr& buffer) const;
36 
37  virtual void saveImage(
38  const std::string& group,
39  const std::string& container,
40  const cv::Mat& image) const;
41 
42  virtual void saveMetaYAML(
43  const std::string& group,
44  const std::string& metaName,
45  const YAML::Node& node) const;
46 
48  const std::string& group,
49  const std::string container) const;
50 
52  const std::string& group,
53  const std::string& container) const;
54 
55  virtual boost::optional<cv::Mat> loadImage(
56  const std::string& group,
57  const std::string& container) const;
58 
59  virtual void loadMetaYAML(
60  const std::string& group,
61  const std::string& container,
62  YAML::Node& node) const;
63 
64  virtual ucharArr loadUCharArray(
65  const std::string& group,
66  const std::string& container,
67  std::vector<size_t> &dims) const;
68 
69  virtual floatArr loadFloatArray(
70  const std::string& group,
71  const std::string& container,
72  std::vector<size_t> &dims) const;
73 
74  virtual doubleArr loadDoubleArray(
75  const std::string& group,
76  const std::string& container,
77  std::vector<size_t> &dims) const;
78 
79  virtual void saveFloatArray(
80  const std::string& groupName,
81  const std::string& datasetName,
82  const std::vector<size_t>& dimensions,
83  const boost::shared_array<float>& data) const;
84 
85  virtual void saveDoubleArray(
86  const std::string& groupName, const std::string& datasetName,
87  const std::vector<size_t>& dimensions,
88  const boost::shared_array<double>& data) const;
89 
90  virtual void saveUCharArray(
91  const std::string& groupName, const std::string& datasetName,
92  const std::vector<size_t>& dimensions,
93  const boost::shared_array<unsigned char>& data) const;
94 
95  virtual bool exists(const std::string& group) const;
96  virtual bool exists(const std::string& group, const std::string& container) const;
97 
98  virtual void subGroupNames(const std::string& group, std::vector<string>& subGroupNames) const;
99  virtual void subGroupNames(const std::string& group, const std::regex& filter, std::vector<string>& subGroupNames) const;
100 
101  template<typename T>
102  boost::shared_array<T> loadArray(
103  const std::string& groupName,
104  const std::string& datasetName,
105  size_t& size) const;
106 
107  template<typename T>
108  boost::shared_array<T> loadArray(
109  const std::string& groupName,
110  const std::string& datasetName,
111  std::vector<size_t>& dim) const;
112 
113  template<typename T>
114  void saveArray(
115  const std::string& groupName,
116  const std::string& datasetName,
117  const size_t& size,
118  const boost::shared_array<T> data) const;
119 
120  template<typename T>
121  void saveArray(
122  const std::string& groupName,
123  const std::string& datasetName,
124  const vector<size_t>& dim,
125  const boost::shared_array<T> data) const;
126 
127  template<typename T>
128  ChannelOptional<T> loadChannelOptional(HighFive::Group& g, const std::string& datasetName) const;
129 
130  template<typename T>
131  ChannelOptional<T> loadChannelOptional(const std::string& groupName, const std::string& datasetName) const;
132 
133  // template<typename T>
134  // ChannelOptional<T> load(
135  // HighFive::Group& g,
136  // std::string datasetName
137  // ) const;
138 
139  template<typename T>
140  void save(std::string groupName,
141  std::string datasetName,
142  const Channel<T>& channel) const;
143 
144  template<typename T>
145  void save(HighFive::Group& g,
146  std::string datasetName,
147  const Channel<T>& channel) const;
148 
149  template<typename T>
150  void save(HighFive::Group& g,
151  std::string datasetName,
152  const Channel<T>& channel,
153  std::vector<hsize_t>& chunkSize) const;
154 
162  bool getChannel(const std::string group, const std::string name, FloatChannelOptional& channel) const;
163 
171  bool getChannel(const std::string group, const std::string name, IndexChannelOptional& channel) const;
172 
180  bool getChannel(const std::string group, const std::string name, UCharChannelOptional& channel) const;
181 
182  template <typename T>
183  bool getChannel(const std::string group, const std::string name, boost::optional<AttributeChannel<T>>& channel) const;
184 
185  template <typename T>
186  bool addChannel(const std::string group, const std::string name, const AttributeChannel<T>& channel) const;
187 
195  bool addChannel(const std::string group, const std::string name, const FloatChannel& channel) const;
196 
204  bool addChannel(const std::string group, const std::string name, const IndexChannel& channel) const;
205 
213  bool addChannel(const std::string group, const std::string name, const UCharChannel& channel) const;
214 
215  template<typename ...Tp>
216  void save(std::string groupName, std::string datasetName, const VariantChannel<Tp...>& vchannel) const;
217 
218  template<typename ...Tp>
219  void save(HighFive::Group& group, std::string datasetName, const VariantChannel<Tp...>& vchannel) const;
220 
221  template<typename VariantChannelT>
222  boost::optional<VariantChannelT> load(std::string groupName, std::string datasetName) const;
223 
224  template<typename VariantChannelT>
225  boost::optional<VariantChannelT> load(HighFive::Group& group, std::string datasetName) const;
226 
227  template<typename VariantChannelT>
228  boost::optional<VariantChannelT> loadVariantChannel(std::string groupName, std::string datasetName) const;
229 
230  template<typename VariantChannelT>
231  boost::optional<VariantChannelT> loadDynamic(HighFive::DataType dtype,
232  HighFive::Group& group,
233  std::string name) const;
234 
235  template<typename ...Tp>
236  void saveDynamic(HighFive::Group& group,
237  std::string datasetName,
238  const VariantChannel<Tp...>& vchannel
239  ) const;
240 
241  template<typename T>
242  cv::Mat createMat(const std::vector<size_t>& dims) const;
243 
244  void loadMetaData(const YAML::Node& node);
245 
246  std::shared_ptr<HighFive::File> m_hdf5File;
247 
249 
250 };
251 
252 using HDF5KernelPtr = std::shared_ptr<HDF5Kernel>;
253 
254 } // namespace lvr2
255 
256 #include "lvr2/io/descriptions/HDF5Kernel.tcc"
257 
258 #endif
VariantChannel.hpp
lvr2::floatArr
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
lvr2::HDF5Kernel::loadMetaData
void loadMetaData(const YAML::Node &node)
Definition: HDF5Kernel.cpp:358
lvr2::HDF5Kernel::m_hdf5File
std::shared_ptr< HighFive::File > m_hdf5File
Definition: HDF5Kernel.hpp:246
lvr2::HDF5Kernel::addChannel
bool addChannel(const std::string group, const std::string name, const AttributeChannel< T > &channel) const
lvr2::IndexChannelOptional
IndexChannel::Optional IndexChannelOptional
Definition: Channel.hpp:100
lvr2::HDF5Kernel::saveMetaYAML
virtual void saveMetaYAML(const std::string &group, const std::string &metaName, const YAML::Node &node) const
Definition: HDF5Kernel.cpp:178
lvr2::HDF5Kernel::saveImage
virtual void saveImage(const std::string &group, const std::string &container, const cv::Mat &image) const
Definition: HDF5Kernel.cpp:37
lvr2::UCharChannelOptional
UCharChannel::Optional UCharChannelOptional
Definition: Channel.hpp:96
lvr2::HDF5Kernel
Definition: HDF5Kernel.hpp:19
lvr2::HDF5Kernel::subGroupNames
virtual void subGroupNames(const std::string &group, std::vector< string > &subGroupNames) const
Definition: HDF5Kernel.cpp:474
lvr2::HDF5KernelPtr
std::shared_ptr< HDF5Kernel > HDF5KernelPtr
Definition: HDF5Kernel.hpp:252
lvr2::HDF5Kernel::load
boost::optional< VariantChannelT > load(std::string groupName, std::string datasetName) const
lvr2::HDF5MetaDescriptionBase
Definition: HDF5MetaDescriptionBase.hpp:16
lvr2::HDF5Kernel::~HDF5Kernel
~HDF5Kernel()
Definition: HDF5Kernel.hpp:25
lvr2::HDF5Kernel::createMat
cv::Mat createMat(const std::vector< size_t > &dims) const
H5File.hpp
HighFive::DataType
HDF5 Data Type.
Definition: H5DataType.hpp:21
lvr2::HDF5Kernel::saveUCharArray
virtual void saveUCharArray(const std::string &groupName, const std::string &datasetName, const std::vector< size_t > &dimensions, const boost::shared_array< unsigned char > &data) const
Definition: HDF5Kernel.cpp:455
lvr2::HDF5Kernel::save
void save(std::string groupName, std::string datasetName, const Channel< T > &channel) const
lvr2::PointBufferPtr
std::shared_ptr< PointBuffer > PointBufferPtr
Definition: PointBuffer.hpp:130
lvr2::HDF5Kernel::saveArray
void saveArray(const std::string &groupName, const std::string &datasetName, const size_t &size, const boost::shared_array< T > data) const
lvr2::HDF5Kernel::loadImage
virtual boost::optional< cv::Mat > loadImage(const std::string &group, const std::string &container) const
Definition: HDF5Kernel.cpp:282
lvr2::HDF5Kernel::loadFloatArray
virtual floatArr loadFloatArray(const std::string &group, const std::string &container, std::vector< size_t > &dims) const
Definition: HDF5Kernel.cpp:422
lvr2::HDF5Kernel::exists
virtual bool exists(const std::string &group) const
Definition: HDF5Kernel.cpp:463
lvr2::HDF5Kernel::saveMeshBuffer
virtual void saveMeshBuffer(const std::string &group, const std::string &container, const MeshBufferPtr &buffer) const
Definition: HDF5Kernel.cpp:15
lvr2::FloatChannelOptional
FloatChannel::Optional FloatChannelOptional
Definition: Channel.hpp:88
lvr2::HDF5Kernel::loadMetaYAML
virtual void loadMetaYAML(const std::string &group, const std::string &container, YAML::Node &node) const
Definition: HDF5Kernel.cpp:363
H5DataSet.hpp
H5DataSpace.hpp
lvr2::HDF5Kernel::saveDoubleArray
virtual void saveDoubleArray(const std::string &groupName, const std::string &datasetName, const std::vector< size_t > &dimensions, const boost::shared_array< double > &data) const
Definition: HDF5Kernel.cpp:447
lvr2::ChannelOptional
typename Channel< T >::Optional ChannelOptional
Definition: Channel.hpp:85
Channel.hpp
HighFive::Group
Definition: H5Group.hpp:20
HDF5MetaDescriptionV2.hpp
FileKernel.hpp
Hdf5Util.hpp
lvr2::HDF5Kernel::loadDoubleArray
virtual doubleArr loadDoubleArray(const std::string &group, const std::string &container, std::vector< size_t > &dims) const
Definition: HDF5Kernel.cpp:430
lvr2::HDF5Kernel::loadVariantChannel
boost::optional< VariantChannelT > loadVariantChannel(std::string groupName, std::string datasetName) const
filter
void filter(lvr2::PointBufferPtr &cloud, lvr2::indexArray &inlier, size_t j)
Definition: src/tools/lvr2_cl_sor/Main.cpp:40
lvr2::Channel
Definition: Channel.hpp:42
lvr2::HDF5Kernel::m_metaDescription
HDF5MetaDescriptionBase * m_metaDescription
Definition: HDF5Kernel.hpp:248
lvr2::HDF5Kernel::saveDynamic
void saveDynamic(HighFive::Group &group, std::string datasetName, const VariantChannel< Tp... > &vchannel) const
lvr2::ucharArr
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::VariantChannel
Definition: VariantChannel.hpp:18
lvr2::MeshBufferPtr
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
lvr2::HDF5Kernel::loadUCharArray
virtual ucharArr loadUCharArray(const std::string &group, const std::string &container, std::vector< size_t > &dims) const
Definition: HDF5Kernel.cpp:414
lvr2::HDF5Kernel::loadPointBuffer
virtual PointBufferPtr loadPointBuffer(const std::string &group, const std::string &container) const
Definition: HDF5Kernel.cpp:231
lvr2::HDF5Kernel::getChannel
bool getChannel(const std::string group, const std::string name, FloatChannelOptional &channel) const
getChannel Reads a float attribute channel in the given group with the given name
Definition: HDF5Kernel.cpp:486
lvr2::HDF5Kernel::saveFloatArray
virtual void saveFloatArray(const std::string &groupName, const std::string &datasetName, const std::vector< size_t > &dimensions, const boost::shared_array< float > &data) const
Definition: HDF5Kernel.cpp:438
lvr2::HDF5Kernel::loadDynamic
boost::optional< VariantChannelT > loadDynamic(HighFive::DataType dtype, HighFive::Group &group, std::string name) const
lvr2::doubleArr
boost::shared_array< double > doubleArr
Definition: DataStruct.hpp:134
lvr2::HDF5Kernel::loadArray
boost::shared_array< T > loadArray(const std::string &groupName, const std::string &datasetName, size_t &size) const
lvr2::HDF5Kernel::HDF5Kernel
HDF5Kernel()=delete
lvr2::HDF5Kernel::loadMeshBuffer
virtual MeshBufferPtr loadMeshBuffer(const std::string &group, const std::string container) const
Definition: HDF5Kernel.cpp:224
lvr2::FileKernel
Definition: FileKernel.hpp:20
lvr2::HDF5Kernel::loadChannelOptional
ChannelOptional< T > loadChannelOptional(HighFive::Group &g, const std::string &datasetName) const
lvr2::HDF5Kernel::savePointBuffer
virtual void savePointBuffer(const std::string &group, const std::string &container, const PointBufferPtr &buffer) const
Definition: HDF5Kernel.cpp:23


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:23