UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
io.cpp
1// UFO
2#include <ufo/io/io.hpp>
3
4// STL
5#include <filesystem>
6#include <format>
7#include <stdexcept>
8
9namespace ufo
10{
11// Cloud
12
13CloudProperties cloudProperties(std::filesystem::path const& file)
14{
15 switch (fileType(file)) {
16 case FileType::OBJ: return cloudPropertiesOBJ(file);
17 case FileType::PCD: return cloudPropertiesPCD(file);
18 case FileType::PLY: return cloudPropertiesPLY(file);
19 case FileType::PTS: return cloudPropertiesPTS(file);
20 case FileType::UFO: return cloudPropertiesUFO(file);
21 case FileType::XYZ: return cloudPropertiesXYZ(file);
22 case FileType::XYZI: return cloudPropertiesXYZI(file);
23 case FileType::XYZN: return cloudPropertiesXYZN(file);
24 case FileType::XYZRGB: return cloudPropertiesXYZRGB(file);
25 case FileType::JPEG: [[fallthrough]];
26 case FileType::PNG: [[fallthrough]];
27 case FileType::UNKNOWN: break;
28 }
29
30 throw std::runtime_error(std::format(
31 "[UFO | Cloud Properties] Unknown point cloud file type: {}", file.c_str()));
32}
33
34// Image
35
36ImageProperties imageProperties(std::filesystem::path const& file)
37{
38 switch (fileType(file)) {
39 case FileType::JPEG: return imagePropertiesJPEG(file);
40 case FileType::PNG: return imagePropertiesPNG(file);
41 case FileType::OBJ: [[fallthrough]];
42 case FileType::PCD: [[fallthrough]];
43 case FileType::PLY: [[fallthrough]];
44 case FileType::PTS: [[fallthrough]];
45 case FileType::UFO: [[fallthrough]];
46 case FileType::XYZ: [[fallthrough]];
47 case FileType::XYZI: [[fallthrough]];
48 case FileType::XYZN: [[fallthrough]];
49 case FileType::XYZRGB: [[fallthrough]];
50 case FileType::UNKNOWN: break;
51 }
52
53 throw std::runtime_error(
54 std::format("[UFO | Image Properties] Unknown image file type: {}", file.c_str()));
55}
56} // namespace ufo
All vision-related classes and functions.
Definition cloud.hpp:49
ImageProperties imagePropertiesPNG(std::filesystem::path const &file)
Reads the metadata of a PNG file without decoding pixel data.
Definition png.cpp:147
@ XYZRGB
ASCII XYZ + RGB colour (.xyzrgb).
@ XYZN
ASCII XYZ + surface normal (.xyzn).
@ XYZI
ASCII XYZ + intensity (.xyzi).
@ PLY
Stanford PLY mesh / point cloud (.ply).
@ PNG
PNG lossless image (.png).
@ PCD
PCL Point Cloud Data (.pcd).
@ UNKNOWN
Unrecognised or missing file extension.
@ PTS
Leica PTS point cloud (.pts).
@ JPEG
JPEG compressed image (.jpeg, .jpg).
@ UFO
Native UFOMap binary format (.ufo).
@ XYZ
ASCII XYZ point cloud (.xyz).
@ OBJ
Wavefront OBJ (.obj).
FileType fileType(std::filesystem::path const &file)
Infers the FileType from the extension of file (case-insensitive).
Definition file_type.cpp:31