UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
file_type.cpp
1// UFO
2#include <ufo/io/file_type.hpp>
3#include <ufo/utility/string.hpp>
4
5// STL
6#include <filesystem>
7#include <string>
8#include <unordered_map>
9
10namespace ufo
11{
12namespace io
13{
14static std::unordered_map<std::string, FileType> const extension_map{
15 {".ufo", FileType::UFO}, //
16 {".xyz", FileType::XYZ}, //
17 {".xyzi", FileType::XYZI}, //
18 {".xyzn", FileType::XYZN}, //
19 {".xyzrgb", FileType::XYZRGB}, //
20 {".pts", FileType::PTS}, //
21 {".ply", FileType::PLY}, //
22 {".pcd", FileType::PCD}, //
23 {".obj", FileType::OBJ}, //
24 {".jpeg", FileType::JPEG}, //
25 {".jpg", FileType::JPEG}, //
26 {".png", FileType::PNG}, //
27 {".qtp", FileType::QTP} //
28};
29} // namespace io
30
31FileType fileType(std::filesystem::path const& file)
32{
33 std::string ext = tolower(file.extension().string());
34
35 if (auto it = io::extension_map.find(ext); io::extension_map.end() != it) {
36 return it->second;
37 } else {
38 return FileType::UNKNOWN;
39 }
40}
41} // namespace ufo
All vision-related classes and functions.
Definition cloud.hpp:49
std::string tolower(std::string s)
Converts all characters in the string to lowercase.
Definition string.cpp:92
FileType
Enumerates all file formats supported by the UFO I/O subsystem.
Definition file_type.hpp:74
@ 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).
@ QTP
UFO quantised-tree point-cloud format (.qtp).
@ 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