Go to the documentation of this file.
39 const std::vector<float>& vertices,
40 const std::vector<uint32_t>& face_ids
42 : m_file(
filename,
hf::File::ReadWrite |
hf::File::Create |
hf::File::Truncate)
46 throw "Could not open file.";
77 return dimensions[0] * dimensions[1];
82 std::vector<float> vertices;
86 vertices.resize(
getSize(dataset));
87 dataset.read(vertices.data());
93 std::vector<uint32_t> indices;
97 indices.resize(
getSize(dataset));
98 dataset.read(indices.data());
104 std::vector<float> normals;
108 normals.resize(
getSize(dataset));
109 dataset.read(normals.data());
115 std::vector<uint8_t>
colors;
121 dataset.read(
colors.data());
127 std::vector<MapImage> textures;
136 textures.push_back(
getImage(imagesGroup, setName));
144 std::unordered_map<MapVertex, std::vector<float>> features;
152 features.reserve(featuresGroup.getNumberObjects());
154 for (
auto name : featuresGroup.listObjectNames())
157 std::vector<float> descriptor;
158 auto dataset = featuresGroup.getDataSet(name);
159 dataset.read(descriptor);
163 std::vector<float> xyz(3);
164 auto vector_attr = dataset.getAttribute(
"vector");
165 vector_attr.read(xyz);
171 features.insert({v, descriptor});
179 std::vector<MapMaterial> materials;
194 std::vector<uint32_t> matFaceIndices;
198 return matFaceIndices;
202 .read(matFaceIndices);
204 return matFaceIndices;
209 std::vector<float> coords;
231 return std::vector<std::string>();
239 std::vector<uint32_t> faceIds;
248 if (!lg.exist(labelName))
253 lg.getDataSet(labelName).read(faceIds);
270 std::vector<float> costs;
292 if (!group.
exist(name))
303 H5IMget_image_info(group.
getId(), name.c_str(), &width, &height, &pixel_size, interlace, &npals);
305 auto bufSize = width * height * pixel_size;
306 std::vector<unsigned char> buf;
308 H5IMread_image(group.
getId(), name.c_str(), buf.data());
323 dataSet.write(normals);
344 const std::string& name = std::to_string(index);
346 if (imagesGroup.exist(name))
351 addImage(imagesGroup, name, width, height, data);
362 .write(matFaceIndices);
374 std::cout <<
"Add or update label" << std::endl;
381 if(group.exist(labelName))
383 std::cout <<
"write to existing label" << std::endl;
384 auto dataset = group.getDataSet(labelName);
385 dataset.write(faceIds);
389 std::cout <<
"write to new label" << std::endl;
391 dataset.write(faceIds);
417 for (
const auto& keypoint_features : keypoints_map)
419 auto dataset = tf.createDataSet<
float>(std::to_string(i),
hf::DataSpace::From(keypoint_features.second));
420 dataset.write(keypoint_features.second);
422 std::vector<float> v = {keypoint_features.first.x, keypoint_features.first.y, keypoint_features.first.z};
443 const uint8_t *pixelBuffer)
445 H5IMmake_image_24bit(group.
getId(), name.c_str(), width, height,
"INTERLACE_PIXEL", pixelBuffer);
453 std::string fullPath = std::string(
LABELS_GROUP) +
"/" + name;
454 result = H5Ldelete(
m_file.
getId(), fullPath.data(), H5P_DEFAULT) > 0;
std::vector< MapMaterial > getMaterials()
Returns materials as MapMaterial.
std::vector< std::string > getLabelGroups()
Returns all available label groups.
std::vector< uint32_t > getMaterialFaceIndices()
Returns material <-> face indices.
std::vector< float > getHeightDifference()
Returns the height difference as float vector.
MapImage getImage(hf::Group group, std::string name)
Returns the image in the group, if it exists. If not an empty struct is returned.
HDF5MapIO(std::string filename)
Opens a map file for reading and writing.
~HDF5MapIO()
Closes main groups and makes sure all buffers are flushed to the file on disc.
std::vector< uint32_t > getFaceIds()
Returns face ids vector.
Group createGroup(const std::string &group_name)
std::vector< std::string > getAllLabelsOfGroup(std::string groupName)
Returns all labels inside the given group.
std::vector< size_t > getDimensions() const
void addHeightDifference(std::vector< float > &diff)
Adds the height difference to the attributes group.
DataSet getDataSet(const std::string &dataset_name, const DataSetAccessProps &accessProps=DataSetAccessProps()) const
void addRoughness(std::vector< float > &roughness)
Adds the roughness to the attributes group.
std::vector< uint32_t > getFaceIdsOfLabel(std::string groupName, std::string labelName)
Returns face ids for the given label inside the group. E.g: label=tree_1 -> groupName=tree; labelName...
std::unordered_map< MapVertex, std::vector< float > > getFeatures()
Returns an map which keys are representing the features point in space and the values are an vector o...
std::vector< std::string > getCostLayers()
returns the names of all available costlayers
std::vector< float > getRoughness()
Returns the roughness as float vector.
static DataSpace From(const ScalarValue &scalar_value)
void addTexture(int index, uint32_t width, uint32_t height, uint8_t *data)
std::vector< float > getVertexCosts(std::string costlayer)
Returns one costlayer as float vector.
void addVertexTextureCoords(std::vector< float > &coords)
Add vertex texture coordinates to the textures group.
static constexpr const char * CHANNELS_GROUP
std::vector< float > getVertexNormals()
Returns vertex normals vector.
DataSpace getSpace() const
std::vector< float > getVertexTextureCoords()
Returns vertex texture coordinates.
void addTextureKeypointsMap(std::unordered_map< MapVertex, std::vector< float >> &keypoints_map)
Adds the keypoints with their corresponding positions to the attributes_group. The position is saved ...
static constexpr const char * LABELS_GROUP
std::vector< MapImage > getTextures()
Returns textures vector.
static constexpr const char * TEXTURES_GROUP
DataSet createDataSet(const std::string &dataset_name, const DataSpace &space, const DataSetCreateProps &createProps=DataSetCreateProps(), const DataSetAccessProps &accessProps=DataSetAccessProps())
hf::DataSet addVertexNormals(std::vector< float > &normals)
Add normals to the attributes group.
void addImage(hf::Group group, std::string name, const uint32_t width, const uint32_t height, const uint8_t *pixelBuffer)
Adds an image with given data set name to the given group.
Group getGroup(const std::string &group_name) const
void addMaterials(std::vector< MapMaterial > &materials, std::vector< uint32_t > &matFaceIndices)
Add materials as MapMaterial and the corresponding material <-> face indices.
hf::Group m_channelsGroup
std::vector< uint8_t > getVertexColors()
Returns vertex colors vector.
static constexpr const char * CLUSTERSETS_GROUP
void flush()
Flushes the file. All opened buffers are saved to disc.
std::vector< float > getVertices()
Returns vertices vector.
void addLabel(std::string groupName, std::string labelName, std::vector< uint32_t > &faceIds)
Adds the label (labelName) to the label group with the given faces. E.g.: tree_1 -> groupName=tree; l...
bool exist(const std::string &node_name) const
hf::Group m_texturesGroup
size_t getSize(hf::DataSet &data_set)
hf::Group m_clusterSetsGroup
void addOrUpdateLabel(std::string groupName, std::string labelName, std::vector< uint32_t > &faceIds)
Adds or updates the label (labelName) to the label group with the given faces. E.g....
std::vector< uint8_t > data
std::vector< std::string > listObjectNames() const
hf::DataSet addVertexColors(std::vector< uint8_t > &colors)
Add vertex colors to the attributes group.
hdf5_map_io
Author(s): Sebastian Pütz
autogenerated on Sun Jan 21 2024 04:06:12