11 namespace pointmatcher
16 py::class_<PMIO> pyPointMatcherIO(p_module,
"PointMatcherIO",
"IO Functions and classes that are dependant on scalar type are defined in this templatized class");
18 pyPointMatcherIO.def(py::init<>())
19 .def_static(
"getColLabel", &
PMIO::getColLabel, py::arg(
"label"), py::arg(
"row"),
"convert a descriptor label to an appropriate sub-label");
22 py::enum_<PMPropTypes>(pyPointMatcherIO,
"PMPropTypes",
"Type of information in a DataPoints. Each type is stored in its own dense matrix.")
23 .value(
"FEATURE", PMPropTypes::FEATURE).value(
"DESCRIPTOR", PMPropTypes::DESCRIPTOR)
24 .value(
"TIME", PMPropTypes::TIME).value(
"UNSUPPORTED", PMPropTypes::UNSUPPORTED);
27 py::class_<SupportedLabel>(pyPointMatcherIO,
"SupportedLabel",
"Structure containing all information required to map external information to PointMatcher internal representation")
28 .def_readwrite(
"internalName", &SupportedLabel::internalName,
"name used in PointMatcher")
29 .def_readwrite(
"externalName", &SupportedLabel::externalName,
"name used in external format")
30 .def_readwrite(
"type", &SupportedLabel::type,
"type of information in PointMatcher")
32 .def(py::init<const std::string&, const std::string&, const PMPropTypes&>(), py::arg(
"internalName"), py::arg(
"externalName"), py::arg(
"type"));
35 py::bind_vector<SupportedLabels>(pyPointMatcherIO,
"SupportedLabels",
"Vector of supported labels in PointMatcher and their external names");
38 py::class_<GenericInputHeader>(pyPointMatcherIO,
"GenericInputHeader",
"Helper structure designed to parse file headers")
40 .def_readwrite(
"matrixRowId", &GenericInputHeader::matrixRowId)
41 .def_readwrite(
"matrixType", &GenericInputHeader::matrixType).def(py::init<>())
42 .def(py::init<const std::string&>(), py::arg(
"name"));
45 Vector containing the mapping of all external names to PointMatcher representation.
46 The order is important (i.e., nx before ny). This can also be used to remap 1D descriptor name to a better one.
50 py::class_<LabelGenerator>(pyPointMatcherIO,
"LabelGenerator").def(py::init<>())
51 .def(
"add", (
void (LabelGenerator::*)(
const std::string)) &LabelGenerator::add, py::arg(
"internalName"),
"add a name to the vector of labels. If already there, will increament the dimension.")
52 .def(
"add", (
void (LabelGenerator::*)(
const std::string,
const unsigned int)) &LabelGenerator::add, py::arg(
"internalName"), py::arg(
"dim"),
"add a name to the vector of labels with its dimension.")
53 .def(
"getLabels", &LabelGenerator::getLabels,
"Return the vector of labels used to build a DataPoints");
57 .def_static(
"saveCSV", (
void (*)(
const DataPoints&,
const std::string&,
unsigned precision)) &
PMIO::saveCSV, py::arg(
"data"), py::arg(
"fileName"), py::arg(
"precision"));
60 py::enum_<SupportedVTKDataTypes>(pyPointMatcherIO,
"SupportedVTKDataTypes",
"Enumeration of legacy VTK data types that can be parsed")
61 .value(
"POLYDATA", SupportedVTKDataTypes::POLYDATA)
62 .value(
"UNSTRUCTURED_GRID", SupportedVTKDataTypes::UNSTRUCTURED_GRID);
65 py::class_<SplitTime>(pyPointMatcherIO,
"SplitTime",
"Storage for time loaded separatly")
66 .def_readwrite(
"isHigh32Found", &SplitTime::isHigh32Found,
"was the high 32bits found in the file")
67 .def_readwrite(
"isLow32Found", &SplitTime::isLow32Found,
"was the low 32bits found in the file")
68 .def_readwrite(
"high32", &SplitTime::high32,
"Matrix containing file data representing the high 32 bits")
69 .def_readwrite(
"low32", &SplitTime::low32,
"Matrix containing file data representing the low 32 bits")
74 .def_static(
"saveVTK", (
void (*)(
const DataPoints&,
const std::string&,
bool,
unsigned precision)) &
PMIO::saveVTK, py::arg(
"data"), py::arg(
"fileName"), py::arg(
"binary") =
false, py::arg(
"precision") = 7)
77 .def_static(
"savePLY", (
void (*)(
const DataPoints&,
const std::string&,
bool binary,
unsigned precision)) &
PMIO::savePLY, py::arg(
"data"), py::arg(
"fileName"), py::arg(
"binary"), py::arg(
"precision"),
"save datapoints to PLY point cloud format")
80 .def_static(
"savePCD", (
void (*)(
const DataPoints&,
const std::string&,
unsigned precision)) &
PMIO::savePCD, py::arg(
"data"), py::arg(
"fileName"), py::arg(
"precision"),
"save datapoints to PCD point cloud format");
83 using Vector3 = FileInfo::Vector3;
84 py::class_<FileInfo>(pyPointMatcherIO,
"FileInfo",
"Information to exploit a reading from a file using this library. Fields might be left blank if unused.")
85 .def_readwrite(
"readingFileName", &FileInfo::readingFileName,
"file name of the reading point cloud")
86 .def_readwrite(
"referenceFileName", &FileInfo::referenceFileName,
"file name of the reference point cloud")
87 .def_readwrite(
"configFileName", &FileInfo::configFileName,
"file name of the yaml configuration")
88 .def_readwrite(
"initialTransformation", &FileInfo::initialTransformation,
"matrix of initial estimate transform")
89 .def_readwrite(
"groundTruthTransformation", &FileInfo::groundTruthTransformation,
"matrix of the ground-truth transform")
90 .def_readwrite(
"gravity", &FileInfo::gravity,
"gravity vector")
92 .def(py::init<const std::string&, const std::string&, const std::string&, const TransformationParameters&, const TransformationParameters&, const Vector&>(), py::arg(
"readingPath") =
"", py::arg(
" referencePath") =
"", py::arg(
"configFileName") =
"", py::arg(
"initialTransformation") =
TransformationParameters(), py::arg(
"groundTruthTransformation") =
TransformationParameters(), py::arg(
"gravity") = Vector3::Zero(),
"Constructor, leave fields blank if unused");
95 py::bind_vector<FileInfoVector>(pyPointMatcherIO,
"FileInfoVector",
"A vector of file info, to be used in batch processing")
96 .def(py::init<>(),
"Empty constructor")
97 .def(py::init<const std::string&, std::string, std::string>(), py::arg(
"fileName"), py::arg(
"dataPath") =
"", py::arg(
"configPath") =
"", R
"pbdoc(
98 Load a vector of FileInfo from a CSV file.
100 @param fileName name of the CSV file
101 @param dataPath path relative to which the point cloud CSV or VTK will be resolved
102 @param configPath path relative to which the yaml configuration files will be resolved
104 The first line of the CSV file must contain a header. The supported tags are:
105 - reading: file name of the reading point cloud
106 - reference: file name of the reference point cloud
107 - config: file name of the YAML configuration of the ICP chain
108 - iTxy: initial transformation, coordinate x,y
109 - gTxy: ground-truth transformation, coordinate x,y
110 Note that the header must at least contain "reading".
114 py::class_<CsvDescriptor>(pyPointMatcherIO,
"CsvDescriptor",
"A structure to hold information about descriptors contained in a CSV file")
116 .def_readwrite(
"start_col", &CsvDescriptor::start_col,
"column number at which descriptor starts")
117 .def_readwrite(
"span", &CsvDescriptor::span,
"number of columns spanned by descriptor");
120 .def_static(
"plyPropTypeValid", &
PMIO::plyPropTypeValid,
"Check that property defined by type is a valid PLY type note: type must be lowercase");
142 py::bind_map<PLYDescPropMap>(pyPointMatcherIO,
"PLYDescPropMap",
"Map from a descriptor name to a list PLY property\nex: \"normals\" -> nx, ny ,nz");
177 py::class_<PLYElementF>(pyPointMatcherIO,
"PLYElementF",
"Factory for PLY elements")
178 .def(
"elementSupported", &PLYElementF::elementSupported, py::arg(
"elem_name"),
"returns true if element named elem_name is supported by this parser")
179 .def_static(
"createElement", &PLYElementF::createElement, py::arg(
"elem_name"), py::arg(
"elem_num"), py::arg(
"offset"),
"factory function, build element defined by name with elem_num elements");
182 py::class_<PCDproperty>(pyPointMatcherIO,
"PCDproperty",
"Information for a PCD property")
183 .def_readwrite(
"field", &PCDproperty::field,
"Name of the property")
184 .def_readwrite(
"size", &PCDproperty::size,
"Size of the property in bytes")
185 .def_readwrite(
"type", &PCDproperty::type,
"Type: I: signed, U: unsigned, F: float")
186 .def_readwrite(
"count", &PCDproperty::count,
"number of dimension")
187 .def_readwrite(
"pmType", &PCDproperty::pmType,
"type of information in PointMatcher")
188 .def_readwrite(
"pmRowID", &PCDproperty::pmRowID,
"row id used in a DataPoints")
193 py::class_<PCDheader>(pyPointMatcherIO,
"PCDheader",
"All information contained in the header of a PCD file")
195 .def_readwrite(
"properties", &PCDheader::properties,
"vector of properties")
196 .def_readwrite(
"width", &PCDheader::width,
"width of sensor matrix")
197 .def_readwrite(
"height", &PCDheader::height,
"height of sensor matrix")
198 .def_readwrite(
"viewPoint", &PCDheader::viewPoint,
"not used")
199 .def_readwrite(
"nbPoints", &PCDheader::nbPoints,
"number of points, same as width*height")
200 .def_readwrite(
"dataType", &PCDheader::dataType,
"ascii or binary")