Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python bindings #56

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ cmake-*
cmake-build*
imgui.ini
install/*
benchmark/*
wandb*
build/*
.outputs/*

# Configuration files (e.g. idea)
.*
Expand All @@ -13,6 +16,7 @@ wandb*
*.so
*.exe
slam
*git.h*

# Commit the .gitignore
!.gitignore
Expand Down
6 changes: 5 additions & 1 deletion cmake/external.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ if (WITH_VIZ3D)
list(APPEND EXTERNAL_DEPENDENCIES viz3d VTK::FiltersCore)
endif ()

if (WITH_PYTHON_BINDING)
list(APPEND EXTERNAL_DEPENDENCIES pybind11::pybind11)
endif ()

# --
SLAM_CHECK_TARGETS(${EXTERNAL_DEPENDENCIES})

Expand All @@ -22,4 +26,4 @@ foreach (target ${EXTERNAL_DEPENDENCIES})
set(__LOCATION "")
endforeach ()

message(INFO " -- [CT-ICP] -- Appending to the INSTALL RPATH the RPATH to the external libraries: \n\t\t[${EXTERNAL_DEPENDENCIES_INSTALL_RPATH}]" )
message(INFO " -- [CT-ICP] -- Appending to the INSTALL RPATH the RPATH to the external libraries: \n\t\t[${EXTERNAL_DEPENDENCIES_INSTALL_RPATH}]")
Binary file added doc/run_slam_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions include/SlamCore/data/buffer_collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,39 @@ namespace slam {
*/
BufferCollection SelectItems(const std::vector<size_t> &indices) const;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Buffer protocol
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// BufferInfo possess all information to construct numpy buffer protocol bindings
// From ItemBuffer(s)
struct BufferInfo {
char *item_data_ptr = nullptr; // The item buffer, starting at the first element of the field
size_t num_items = 0; // The number of items in the buffer
size_t item_size = 0; // The item size (or the stride between two field in the item buffer)
size_t field_size = 0; // The size of each field
size_t dimensions = 0; // The dimension of the field
slam::PROPERTY_TYPE property_type; // The elementary property type of the field
};

bool IsElementAValidBufferInfo(const std::string &element_name) const;

/*! @returns A buffer info corresponding to an element
*
* @warning A BufferInfo is only valid if the element has an homogeneous type (with one unique property type)
* If this is not the case, the
*/
BufferInfo GetBufferInfoFromElement(const std::string &element_name) const;

/*! @returns A buffer info corresponding to a property
*/
BufferInfo GetBufferInfoFromProperty(const std::string &element_name, const std::string &pty_name) const;

private:
std::vector<ItemBufferPtr> item_buffers;

friend struct PointCloud; // Allows the Point Cloud access the item buffers

// Returns whether the sizes are consistent
static bool AreSizesConsistent(const std::vector<ItemBufferPtr> &buffer);

Expand Down
4 changes: 2 additions & 2 deletions include/SlamCore/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ namespace slam {
void WritePLY(const std::string &file, const std::vector<slam::WPoint3D> &points);

// Writes a point cloud to a file
void WritePLY(std::ostream &output_file, const PointCloud &pointcloud, const PLYSchemaMapper &schema);;
void WritePLY(std::ostream &output_file, const PointCloud &pointcloud, const PLYSchemaMapper &schema);

// Writes a point cloud to a file
void WritePLY(const std::string &file, const PointCloud &points, const PLYSchemaMapper &schema);;
void WritePLY(const std::string &file, const PointCloud &points, const PLYSchemaMapper &schema);

// Writes a buffer collection to a file
void WritePLY(const std::string &output_file, const BufferCollection &collection, const PLYSchemaMapper &schema);
Expand Down
15 changes: 10 additions & 5 deletions include/SlamCore/pointcloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace slam {
int name ## Dimension() const { return sizeof(default_type) / PropertySize(property_type);};\
public: \
inline Field Get ## name ## Field() const { \
SLAM_CHECK_STREAM(element_name .has_value(), "The field ##element_name is not defined !"); \
SLAM_CHECK_STREAM(element_name .has_value(), "The field " #element_name " is not defined !"); \
return element_name .value(); \
} \
inline bool IsValid ## name () const { \
Expand All @@ -194,22 +194,22 @@ namespace slam {
} \
template<typename DataT> \
View<DataT> name() { \
SLAM_CHECK_STREAM(element_name.has_value(), "The field ##element_name is not defined !"); \
SLAM_CHECK_STREAM(element_name.has_value(), "The field " #element_name " is not defined !"); \
return FieldView<DataT>(*element_name); \
} \
template<typename ScalarT> \
const View<ScalarT> name() const { \
SLAM_CHECK_STREAM(element_name.has_value(), "The field ##element_name is not defined !"); \
SLAM_CHECK_STREAM(element_name.has_value(), "The field " #element_name " is not defined !"); \
return FieldView<ScalarT>(*element_name); \
} \
template<typename ScalarT> \
ProxyView<ScalarT> name ## Proxy() { \
SLAM_CHECK_STREAM(element_name.has_value(), "The field ##element_name is not defined !"); \
SLAM_CHECK_STREAM(element_name.has_value(), "The field " #element_name " is not defined !"); \
return ProxyFieldView<ScalarT>(*element_name); \
} \
template<typename ScalarT> \
const ProxyView<ScalarT> name ## Proxy() const { \
SLAM_CHECK_STREAM(element_name.has_value(), "The field ##element_name is not defined !"); \
SLAM_CHECK_STREAM(element_name.has_value(), "The field " #element_name " is not defined !"); \
return ProxyFieldView<ScalarT>(*element_name); \
} \
void Set ## name ## Field(Field&& field ) { \
Expand Down Expand Up @@ -267,6 +267,11 @@ namespace slam {
/// Schema Infos & Management
////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// Returns Buffer information about the point cloud
// /!\ This is a dangerous operation, as the pointer allows to modify raw data despite the const of this method
BufferCollection::BufferInfo GetBufferInfoFromField(const Field &field) const;;

// Returns a const reference to the underlying buffer collection
const BufferCollection &GetCollection() const;

Expand Down
Loading