14 py::class_<DataPoints> pyDataPoints(p_class,
"DataPoints");
16 pyDataPoints.doc() = R
"pbdoc( 19 For every point, it has features and, optionally, descriptors. 20 Features are typically the coordinates of the point in the space. 21 Descriptors contain information attached to the point, such as its color, its normal vector, etc. 22 In both features and descriptors, every point can have multiple channels. 23 Every channel has a dimension and a name. 24 For instance, a typical 3D cloud might have the channels \c x, \c y, \c z, \c w of dimension 1 as features (using homogeneous coordinates), and the channel \c normal of size 3 as descriptor. 25 There are no sub-channels, such as \c normal.x, for the sake of simplicity. 26 Moreover, the position of the points is in homogeneous coordinates because they need both translation and rotation, while the normals need only rotation. 27 All channels contain scalar values of type ScalarType.)pbdoc"; 29 py::class_<Label>(pyDataPoints, "Label").def_readwrite(
"text", &
Label::text,
"name of the label")
30 .def_readwrite(
"span", &
Label::span,
"number of data dimensions the label spans")
32 .def(py::init<const std::string&, const size_t>(), py::arg(
"text") =
"", py::arg(
"span") = 0)
33 .def(
"__eq__", &Label::operator==, py::arg(
"that"));
35 py::bind_vector<Labels>(pyDataPoints,
"Labels",
"A vector of Label")
36 .def(py::init<>(),
"Construct empty Labels")
37 .def(py::init<const Label&>(), py::arg(
"label"),
"Construct Labels with a single Label in it")
39 .def(
"contains", &
Labels::contains, py::arg(
"text"),
"Return whether there is a label named text")
40 .def(
"totalDim", &
Labels::totalDim,
"Return the sum of the spans of each label")
41 .def(
"__str__", [](
const Labels&
self)
43 std::ostringstream oss;
49 py::register_exception<InvalidField>(pyDataPoints,
"InvalidField");
55 .def(py::init<const Labels&, const Labels&, const size_t>(), py::arg(
"featureLabels"), py::arg(
"descriptorLabels"), py::arg(
"pointCount"))
57 .def(py::init<const Labels&, const Labels&, const Labels&, const size_t>(), py::arg(
"featureLabels"), py::arg(
"descriptorLabels"), py::arg(
"timeLabels"), py::arg(
"pointCount"))
60 .def(py::init<const DataPoints&>())
63 .def(py::init<const Matrix&, const Labels&>(), py::arg(
"features"), py::arg(
"featureLabels"))
65 .def(py::init<const Matrix&, const Labels&, const Matrix&, const Labels&>(), py::arg(
"features"), py::arg(
"featureLabels"), py::arg(
"descriptors"), py::arg(
"descriptorLabels"))
67 .def(py::init<const Matrix&, const Labels&, const Matrix&, const Labels&, const PM::Int64Matrix&, const Labels&>(), py::arg(
"features"), py::arg(
"featureLabels"), py::arg(
"descriptors"), py::arg(
"descriptorLabels"), py::arg(
"times"), py::arg(
"timeLabels"))
69 .def(
"__eq__", &DataPoints::operator==, py::arg(
"that"))
76 .def(
"save", &
DataPoints::save, py::arg(
"fileName"), py::arg(
"binary") =
false)
92 .def(
"getFeatureViewByName", (View (
DataPoints::*)(
const std::string&)) &DataPoints::getFeatureViewByName, py::arg(
"name"))
94 .def(
"getFeatureRowViewByName", (View (
DataPoints::*)(
const std::string&,
const unsigned)) &DataPoints::getFeatureRowViewByName, py::arg(
"name"), py::arg(
"row"))
96 .def(
"featureExists", (
bool (
DataPoints::*)(
const std::string&,
const unsigned)
const) &DataPoints::featureExists, py::arg(
"name"), py::arg(
"dim"))
106 .def(
"getDescriptorViewByName", (View (
DataPoints::*)(
const std::string&)) &DataPoints::getDescriptorViewByName, py::arg(
"name"))
108 .def(
"getDescriptorRowViewByName", (View (
DataPoints::*)(
const std::string&,
const unsigned)) &DataPoints::getDescriptorRowViewByName, py::arg(
"name"), py::arg(
"row"))
110 .def(
"descriptorExists", (
bool (
DataPoints::*)(
const std::string&,
const unsigned)
const) &DataPoints::descriptorExists)
121 .def(
"getTimeViewByName", (TimeView (
DataPoints::*)(
const std::string&)) &DataPoints::getTimeViewByName, py::arg(
"name"))
123 .def(
"getTimeRowViewByName", (TimeView (
DataPoints::*)(
const std::string&,
const unsigned)) &DataPoints::getTimeRowViewByName, py::arg(
"name"), py::arg(
"row"))
125 .def(
"timeExists", (
bool (
DataPoints::*)(
const std::string&,
const unsigned)
const) &DataPoints::timeExists, py::arg(
"name"), py::arg(
"dim"))
167 .def_readwrite(
"times", &
DataPoints::times,
"time associated to each points, might be empty")
Matrix getFeatureCopyByName(const std::string &name) const
Get feature by name, return a matrix containing a copy of the requested feature.
void allocateDescriptor(const std::string &name, const unsigned dim)
Makes sure a descriptor of a given name exists, if present, check its dimensions. ...
void allocateTime(const std::string &name, const unsigned dim)
Makes sure a time of a given name exists, if present, check its dimensions.
void allocateTimes(const Labels &newLabels)
Make sure a vector of time of given names exist.
const Eigen::Block< const Int64Matrix > TimeConstView
a view on a const time
unsigned getTimeDimension(const std::string &name) const
Return the dimension of a time with a given name. Return 0 if the name is not found.
unsigned getTimeDim() const
Return the total number of times.
Matrix descriptors
descriptors of points in the cloud, might be empty
void removeTime(const std::string &name)
Remove a descriptor by name, the whole matrix will be copied.
bool timeExists(const std::string &name) const
Look if a time with a given name exist.
Eigen::Block< Int64Matrix > TimeView
A view on a time.
void setColFrom(Index thisCol, const DataPoints &that, Index thatCol)
Set column thisCol equal to column thatCol of that, copy features and descriptors if any...
void assertDescriptorConsistency() const
Assert if descriptors are not consistent with features.
ConstView getFeatureRowViewByName(const std::string &name, const unsigned row) const
Get a const view on a feature row by name and number, throw an exception if it does not exist...
Matrix::Index Index
An index to a row or a column.
ConstView getDescriptorViewByName(const std::string &name) const
Get a const view on a descriptor by name, throw an exception if it does not exist.
unsigned getNbPoints() const
Return the number of points contained in the point cloud.
unsigned getFeatureStartingRow(const std::string &name) const
Return the starting row of a feature with a given name. Return 0 if the name is not found...
unsigned getNbGroupedDescriptors() const
Return the number of grouped descriptors (e.g., normals can have 3 components but would count as only...
Labels featureLabels
labels of features
TimeConstView getTimeRowViewByName(const std::string &name, const unsigned row) const
Get a const view on a time row by name and number, throw an exception if it does not exist...
unsigned getDescriptorDimension(const std::string &name) const
Return the dimension of a descriptor with a given name. Return 0 if the name is not found...
Labels timeLabels
labels of times.
unsigned getDescriptorStartingRow(const std::string &name) const
Return the starting row of a descriptor with a given name. Return 0 if the name is not found...
TimeConstView getTimeViewByName(const std::string &name) const
Get a const view on a time by name, throw an exception if it does not exist.
void pybindDataPoints(py::class_< PM > &p_class)
Matrix getDescriptorCopyByName(const std::string &name) const
Get descriptor by name, return a matrix containing a copy of the requested descriptor.
unsigned getHomogeneousDim() const
Return the dimension of the point cloud in homogeneous coordinates (one more than Euclidean dimension...
void removeDescriptor(const std::string &name)
Remove a descriptor by name, the whole matrix will be copied.
const Eigen::Block< const Matrix > ConstView
A view on a const feature or const descriptor.
void concatenate(const DataPoints &dp)
Add another point cloud after the current one. Faster merge will be achieved if all descriptor and ti...
unsigned getTimeStartingRow(const std::string &name) const
Return the starting row of a time with a given name. Return 0 if the name is not found.
bool featureExists(const std::string &name) const
Look if a feature with a given name exist.
bool descriptorExists(const std::string &name) const
Look if a descriptor with a given name exist.
bool contains(const std::string &text) const
Return whether there is a label named text.
void swapCols(Index iCol, Index jCol)
Swap column i and j in the point cloud, swap also features and descriptors if any. Assumes sizes are similar.
ConstView getDescriptorRowViewByName(const std::string &name, const unsigned row) const
Get a const view on a descriptor row by name and number, throw an exception if it does not exist...
void allocateFeatures(const Labels &newLabels)
Make sure a vector of features of given names exist.
void conservativeResize(Index pointCount)
Resize the cloud to pointCount points, conserving existing ones.
void addFeature(const std::string &name, const Matrix &newFeature)
Add a feature by name, remove first if already exists. The 'pad' field will stay at the end for homog...
size_t span
number of data dimensions the label spans
void assertTimesConsistency() const
Assert if times are not consistent with features.
Eigen::Block< Matrix > View
A view on a feature or descriptor.
void save(const std::string &fileName, bool binary=false) const
Save a point cloud to a file, determine format from extension.
An exception thrown when one tries to access features or descriptors unexisting or of wrong dimension...
void allocateFeature(const std::string &name, const unsigned dim)
Makes sure a feature of a given name exists, if present, check its dimensions.
Int64Matrix times
time associated to each points, might be empty
void addTime(const std::string &name, const Int64Matrix &newTime)
Add a time by name, remove first if already exists.
size_t totalDim() const
Return the sum of the spans of each label.
Matrix features
features of points in the cloud
DataPoints createSimilarEmpty() const
Create an empty DataPoints of similar dimensions and labels for features, descriptors and times...
unsigned getFeatureDimension(const std::string &name) const
Return the dimension of a feature with a given name. Return 0 if the name is not found.
unsigned getDescriptorDim() const
Return the total number of descriptors.
static DataPoints load(const std::string &fileName)
Load a point cloud from a file, determine format from extension.
void addDescriptor(const std::string &name, const Matrix &newDescriptor)
Add a descriptor by name, remove first if already exists.
void allocateDescriptors(const Labels &newLabels)
Make sure a vector of descriptors of given names exist.
unsigned getEuclideanDim() const
Return the dimension of the point cloud.
std::string text
name of the label
Int64Matrix getTimeCopyByName(const std::string &name) const
Get time by name, return a matrix containing a copy of the requested time.
void removeFeature(const std::string &name)
Remove a feature by name, the whole matrix will be copied.
Labels descriptorLabels
labels of descriptors
ConstView getFeatureViewByName(const std::string &name) const
Get a const view on a feature by name, throw an exception if it does not exist.