25 py::class_<Voxel, std::shared_ptr<Voxel>> voxel(
26 m,
"Voxel",
"Base Voxel class, containing grid id and color");
27 py::detail::bind_default_constructor<Voxel>(voxel);
28 py::detail::bind_copy_functions<Voxel>(voxel);
30 [](
const Voxel &voxel) {
31 std::ostringstream repr;
32 repr <<
"Voxel with grid_index: (" << voxel.grid_index_(0)
33 <<
", " << voxel.grid_index_(1) <<
", "
34 << voxel.grid_index_(2) <<
"), color: ("
35 << voxel.color_(0) <<
", " << voxel.color_(1) <<
", "
36 << voxel.color_(2) <<
")";
40 return new Voxel(grid_index);
44 const Eigen::Vector3d &
color) {
47 "grid_index"_a,
"color"_a)
49 "Int numpy array of shape (3,): Grid coordinate "
50 "index of the voxel.")
53 "Float64 numpy array of shape (3,): Color of the voxel.");
55 py::class_<geometry::VoxelGrid, PyGeometry<geometry::VoxelGrid>,
56 std::shared_ptr<geometry::VoxelGrid>,
ccHObject>
57 voxelgrid(m,
"VoxelGrid",
58 "VoxelGrid is a collection of voxels which are aligned "
61 py::native_enum<geometry::VoxelGrid::VoxelPoolingMode>(
62 voxelgrid,
"VoxelPoolingMode",
"enum.Enum",
63 "Mode of determining color for each voxel.")
69 py::detail::bind_default_constructor<geometry::VoxelGrid>(voxelgrid);
70 py::detail::bind_copy_functions<geometry::VoxelGrid>(voxelgrid);
74 return std::string(
"VoxelGrid with ") +
78 .def(py::self + py::self)
79 .def(py::self += py::self)
81 "Returns List of ``Voxel``: Voxels contained in voxel grid. "
82 "Changes to the voxels returned from this method"
83 "are not reflected in the voxel grid.")
85 "Returns ``True`` if the voxel grid contains voxel colors.")
87 "Returns ``True`` if the voxel grid contains voxels.")
89 "Returns voxel index given query point.")
91 "Add a new voxel into the VoxelGrid.")
93 "Remove a voxel given index.")
95 "Element-wise check if a query in the list is included in "
96 "the VoxelGrid. Queries are double precision and "
97 "are mapped to the closest voxel.")
99 "camera_params"_a,
"keep_voxels_outside_image"_a =
false,
100 "Remove all voxels from the VoxelGrid where none of the "
101 "boundary points of the voxel projects to depth value that is "
102 "smaller, or equal than the projected depth of the boundary "
103 "point. If keep_voxels_outside_image is true then voxels are "
104 "only carved if all boundary points project to a valid image "
107 "silhouette_mask"_a,
"camera_params"_a,
108 "keep_voxels_outside_image"_a =
false,
109 "Remove all voxels from the VoxelGrid where none of the "
110 "boundary points of the voxel projects to a valid mask pixel "
111 "(pixel value > 0). If keep_voxels_outside_image is true then "
112 "voxels are only carved if all boundary points project to a "
113 "valid image location.")
115 "Convert to Octree.")
117 "Convert from Octree.")
119 "Creates a voxel grid where every voxel is set (hence "
120 "dense). This is a useful starting point for voxel "
122 "origin"_a,
"color"_a,
"voxel_size"_a,
"width"_a,
123 "height"_a,
"depth"_a)
126 "Creates a VoxelGrid from a given PointCloud. The "
127 "color value of a given voxel is determined by the "
128 "VoxelPoolingMode, e.g. by default the average color "
129 "value of the points that fall into it (if the "
130 "PointCloud has colors). The bounds of the created "
131 "VoxelGrid are computed from the PointCloud.",
132 "input"_a,
"voxel_size"_a,
134 "VoxelPoolingMode.AVG"))
136 "create_from_point_cloud_within_bounds",
138 "Creates a VoxelGrid from a given PointCloud. The "
139 "color value of a given voxel is determined by the "
140 "VoxelPoolingMode, e.g. by default the average color "
141 "value of the points that fall into it (if the "
142 "PointCloud has colors). The bounds of the created "
143 "VoxelGrid are defined by the given parameters.",
144 "input"_a,
"voxel_size"_a,
"min_bound"_a,
"max_bound"_a,
146 "VoxelPoolingMode.AVG"))
147 .def_static(
"create_from_triangle_mesh",
149 "Creates a VoxelGrid from a given TriangleMesh. No "
150 "color information is converted. The bounds of the "
151 "created VoxelGrid are computed from the "
153 "input"_a,
"voxel_size"_a)
155 "create_from_triangle_mesh_within_bounds",
157 "Creates a VoxelGrid from a given TriangleMesh. No color "
158 "information is converted. The bounds "
159 "of the created VoxelGrid are defined by the given "
161 "input"_a,
"voxel_size"_a,
"min_bound"_a,
"max_bound"_a)
163 "``float64`` vector of length 3: Coorindate of the "
166 "``float64`` 3x3 matrix: Rotation matrix of the "
169 "``float64`` Size of the voxel.");
173 {{
"point",
"The query point."}});
175 {{
"Voxel",
"A new voxel."}});
177 m,
"VoxelGrid",
"remove_voxel",
178 {{
"idx",
"The grid index of the target voxel."}});
180 m,
"VoxelGrid",
"check_if_included",
181 {{
"query",
"a list of voxel indices to check."}});
183 m,
"VoxelGrid",
"carve_depth_map",
184 {{
"depth_map",
"Depth map (Image) used for VoxelGrid carving."},
185 {
"camera_parameters",
186 "PinholeCameraParameters used to record the given depth_map."},
187 {
"keep_voxels_outside_image",
188 "retain voxels that don't project"
189 " to pixels in the image"}});
191 m,
"VoxelGrid",
"carve_silhouette",
193 "Silhouette mask (Image) used for VoxelGrid carving."},
194 {
"camera_parameters",
195 "PinholeCameraParameters used to record the given depth_map."},
196 {
"keep_voxels_outside_image",
197 "retain voxels that don't project"
198 " to pixels in the image"}});
200 m,
"VoxelGrid",
"to_octree",
201 {{
"max_depth",
"int: Maximum depth of the octree."}});
203 m,
"VoxelGrid",
"create_from_octree",
204 {{
"octree",
"geometry.Octree: The source octree."}});
206 m,
"VoxelGrid",
"create_dense",
207 {{
"origin",
"Coordinate center of the VoxelGrid"},
208 {
"color",
"Voxel color for all voxels if the VoxelGrid."},
209 {
"voxel_size",
"Voxel size of of the VoxelGrid construction."},
210 {
"width",
"Spatial width extend of the VoxelGrid."},
211 {
"height",
"Spatial height extend of the VoxelGrid."},
212 {
"depth",
"Spatial depth extend of the VoxelGrid."}});
214 m,
"VoxelGrid",
"create_from_point_cloud",
215 {{
"input",
"The input PointCloud"},
216 {
"voxel_size",
"Voxel size of the VoxelGrid construction."},
218 "VoxelPoolingMode for determining voxel color."}});
220 m,
"VoxelGrid",
"create_from_point_cloud_within_bounds",
221 {{
"input",
"The input PointCloud"},
222 {
"voxel_size",
"Voxel size of the VoxelGrid construction."},
224 "Minimum boundary point for the VoxelGrid to create."},
226 "Maximum boundary point for the VoxelGrid to create."},
228 "VoxelPoolingMode that determines how to compute the voxel "
231 m,
"VoxelGrid",
"create_from_triangle_mesh",
232 {{
"input",
"The input TriangleMesh"},
233 {
"voxel_size",
"Voxel size of of the VoxelGrid construction."}});
235 m,
"VoxelGrid",
"create_from_triangle_mesh_within_bounds",
236 {{
"input",
"The input TriangleMesh"},
237 {
"voxel_size",
"Voxel size of of the VoxelGrid construction."},
239 "Minimum boundary point for the VoxelGrid to create."},
241 "Maximum boundary point for the VoxelGrid to create."}});
Hierarchical CLOUDVIEWER Object.
VoxelGrid is a collection of voxels which are aligned in grid.
Eigen::Matrix3d rotation_
void CreateFromOctree(const Octree &octree)
VoxelGrid & CarveDepthMap(const Image &depth_map, const camera::PinholeCameraParameters &camera_parameter, bool keep_voxels_outside_image)
double voxel_size_
Size of the voxel.
static std::shared_ptr< VoxelGrid > CreateFromTriangleMesh(const ccMesh &input, double voxel_size)
VoxelGrid & CarveSilhouette(const Image &silhouette_mask, const camera::PinholeCameraParameters &camera_parameter, bool keep_voxels_outside_image)
static std::shared_ptr< VoxelGrid > CreateFromPointCloud(const ccPointCloud &input, double voxel_size, VoxelPoolingMode color_mode=VoxelPoolingMode::AVG)
bool HasColors() const
Returns true if the voxel grid contains voxel colors.
bool HasVoxels() const
Returns true if the voxel grid contains voxels.
std::shared_ptr< geometry::Octree > ToOctree(const size_t &max_depth) const
static std::shared_ptr< VoxelGrid > CreateFromPointCloudWithinBounds(const ccPointCloud &input, double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound, VoxelPoolingMode color_mode=VoxelPoolingMode::AVG)
std::vector< bool > CheckIfIncluded(const std::vector< Eigen::Vector3d > &queries)
Eigen::Vector3d origin_
Coorindate of the origin point.
Eigen::Vector3i GetVoxel(const Eigen::Vector3d &point) const
Returns voxel index given query point.
static std::shared_ptr< VoxelGrid > CreateDense(const Eigen::Vector3d &origin, const Eigen::Vector3d &color, double voxel_size, double width, double height, double depth)
void RemoveVoxel(const Eigen::Vector3i &idx)
Remove a voxel with specified grid index.
void AddVoxel(const Voxel &voxel)
Add a voxel with specified grid index and color.
std::vector< Voxel > GetVoxels() const
static std::shared_ptr< VoxelGrid > CreateFromTriangleMeshWithinBounds(const ccMesh &input, double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound)
Base Voxel class, containing grid id and color.
Eigen::Vector3i grid_index_
Grid coordinate index of the voxel.
Eigen::Vector3d color_
Color of the voxel.
void ClassMethodDocInject(py::module &pybind_module, const std::string &class_name, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
void pybind_voxelgrid(py::module &m)
void pybind_voxelgrid_methods(py::module &m)
Generic file read and write utility for python interface.
Eigen::Matrix< Index, 3, 1 > Vector3i
std::string to_string(const T &n)