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");
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")
77 .def_static(
"savePLY", (
void (*)(
const DataPoints&,
const std::string&)) &
PMIO::savePLY, py::arg(
"data"), py::arg(
"fileName"),
"save datapoints to PLY point cloud format")
80 .def_static(
"savePCD", (
void (*)(
const DataPoints&,
const std::string&)) &
PMIO::savePCD, py::arg(
"data"), py::arg(
"fileName"),
"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");
123 py::class_<PLYProperty>(pyPointMatcherIO,
"PLYProperty",
"Interface for PLY property")
125 .def_readwrite(
"type", &PLYProperty::type,
"type of PLY property")
126 .def_readwrite(
"idx_type", &PLYProperty::idx_type,
"for list properties, type of number of elements")
127 .def_readwrite(
"pos", &PLYProperty::pos,
"index of the property in element")
128 .def_readwrite(
"is_list", &PLYProperty::is_list,
"member is true of property is a list")
129 .def_readwrite(
"pmType", &PLYProperty::pmType,
"type of information in PointMatcher")
130 .def_readwrite(
"pmRowID", &PLYProperty::pmRowID,
"row id used in a DataPoints")
132 .def(py::init<>(),
"Default constructor. If used member values must be filled later.")
133 .def(py::init<const std::string&, const std::string&, const unsigned>(), py::arg(
"type"), py::arg(
"name"), py::arg(
"pos"),
"regular property")
134 .def(py::init<const std::string&, const std::string&, const std::string&, const unsigned>(), py::arg(
"idx_type"), py::arg(
"type"), py::arg(
"name"), py::arg(
"pos"),
"list property")
136 .def(
"__eq__", &PLYProperty::operator==,
"compare with other property");
139 py::bind_vector<PLYProperties>(pyPointMatcherIO,
"PLYProperties",
"Vector of properties specific to PLY files");
142 py::bind_map<PLYDescPropMap>(pyPointMatcherIO,
"PLYDescPropMap",
"Map from a descriptor name to a list PLY property\nex: \"normals\" -> nx, ny ,nz");
145 py::class_<PLYElement>(pyPointMatcherIO,
"PLYElement",
"Interface for all PLY elements.")
146 .def_readwrite(
"name", &
PLYElement::name,
"name identifying the PLY element")
147 .def_readwrite(
"num", &PLYElement::num,
"number of occurences of the element")
148 .def_readwrite(
"total_props", &PLYElement::total_props,
"total number of properties in PLY element")
149 .def_readwrite(
"offset", &PLYElement::offset,
"line at which data starts")
150 .def_readwrite(
"properties", &PLYElement::properties,
"all properties found in the header")
151 .def_readwrite(
"nbFeatures", &PLYElement::nbFeatures,
"number of valid features found in the header")
152 .def_readwrite(
"nbDescriptors", &PLYElement::nbDescriptors,
"number of valid descriptors found in the header")
154 .def(py::init<const std::string&, const unsigned, const unsigned>(), py::arg(
"name"), py::arg(
"num"), py::arg(
"offset"), R
"pbdoc( 155 PLY Element constructor 157 @param name name of the ply element (case-sensitive) 158 @param num number of times the element appears in the file 159 @param offset if there are several elements, the line offset at which this element begins. Note that, as of writing, only one (vertex) element is supported. 161 This object holds information about a PLY element contained in the file. 162 It is filled out when reading the header and used when parsing the data. 163 )pbdoc").def("__eq__", &PLYElement::operator==,
"comparison operator for elements");
166 py::class_<PLYVertex, PLYElement>(pyPointMatcherIO,
"PLYVertex",
"Implementation of PLY vertex element")
167 .def(py::init<const unsigned, const unsigned>(), py::arg(
"num"), py::arg(
"offset"), R
"pbdoc( 170 @param num number of times the element appears in the file 171 @param offset if there are several elements, the line offset at which this element begins. Note that, as of writing, only one (vertex) element is supported. 173 Implementation of PLY element interface for the vertex element 183 py::class_<PCDproperty>(pyPointMatcherIO,
"PCDproperty",
"Information for a PCD property")
184 .def_readwrite(
"field", &PCDproperty::field,
"Name of the property")
185 .def_readwrite(
"size", &PCDproperty::size,
"Size of the property in bytes")
186 .def_readwrite(
"type", &PCDproperty::type,
"Type: I: signed, U: unsigned, F: float")
187 .def_readwrite(
"count", &PCDproperty::count,
"number of dimension")
188 .def_readwrite(
"pmType", &PCDproperty::pmType,
"type of information in PointMatcher")
189 .def_readwrite(
"pmRowID", &PCDproperty::pmRowID,
"row id used in a DataPoints")
194 py::class_<PCDheader>(pyPointMatcherIO,
"PCDheader",
"All information contained in the header of a PCD file")
196 .def_readwrite(
"properties", &PCDheader::properties,
"vector of properties")
197 .def_readwrite(
"width", &PCDheader::width,
"width of sensor matrix")
198 .def_readwrite(
"height", &PCDheader::height,
"height of sensor matrix")
199 .def_readwrite(
"viewPoint", &PCDheader::viewPoint,
"not used")
200 .def_readwrite(
"nbPoints", &PCDheader::nbPoints,
"number of points, same as width*height")
201 .def_readwrite(
"dataType", &PCDheader::dataType,
"ascii or binary")
void pybindIO(py::module &p_module)
IO Functions and classes that are dependant on scalar type are defined in this templatized class...
static DataPoints loadPCD(const std::string &fileName)
std::vector< SupportedLabel > SupportedLabels
Vector of supported labels in PointMatcher and their external names.
static bool plyPropTypeValid(const std::string &type)
Check that property defined by type is a valid PLY type note: type must be lowercase.
static void savePLY(const DataPoints &data, const std::string &fileName)
save datapoints to PLY point cloud format
static void saveVTK(const DataPoints &data, const std::string &fileName, bool binary=false)
Save point cloud to a file as VTK.
static DataPoints loadCSV(const std::string &fileName)
Associate an external name to a DataPoints type of information.
static DataPoints loadPLY(const std::string &fileName)
Load polygon file format (ply) file.
static const SupportedLabels & getSupportedExternalLabels()
static void saveCSV(const DataPoints &data, const std::string &fileName)
Save point cloud to a file as CSV.
Information for a PCD property.
static void savePCD(const DataPoints &data, const std::string &fileName)
save datapoints to PCD point cloud format
A structure to hold information about descriptors contained in a CSV file.
Information to exploit a reading from a file using this library. Fields might be left blank if unused...
SupportedVTKDataTypes
Enumeration of legacy VTK data types that can be parsed.
Storage for time loaded separatly.
static std::string getColLabel(const Label &label, const int row)
convert a descriptor label to an appropriate sub-label
Structure containing all information required to map external information to PointMatcher internal re...
A vector of file info, to be used in batch processing.
Generate a vector of Labels by checking for collision is the same name is reused. ...
Interface for PLY property.
PMPropTypes
Type of information in a DataPoints. Each type is stored in its own dense matrix. ...
PM::TransformationParameters TransformationParameters
std::map< std::string, std::vector< PLYProperty > > PLYDescPropMap
Implementation of PLY vertex element.
PM::ScalarType ScalarType
Interface for all PLY elements.
std::vector< PLYProperty > PLYProperties
Vector of properties specific to PLY files.
static DataPoints loadVTK(const std::string &fileName)
Load point cloud from a file as VTK.