How to use the pyntcloud.structures.VoxelGrid function in pyntcloud

To help you get started, we’ve selected a few pyntcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daavoo / pyntcloud / tests / unit / structures / test_voxelgrid_structures.py View on Github external
def test_expected_voxel_n_for_different_number_of_voxels_per_axis(simple_pyntcloud, n_x, n_y, n_z, expected_voxel_n):
    voxelgrid = VoxelGrid(points=simple_pyntcloud.xyz, n_x=n_x, n_y=n_y, n_z=n_z)
    voxelgrid.compute()
    assert np.all(voxelgrid.voxel_n == expected_voxel_n)
github daavoo / pyntcloud / tests / unit / structures / test_voxelgrid_structures.py View on Github external
def test_output_shape_of_all_feature_vector_modes(mode, simple_pyntcloud):
    voxelgrid = VoxelGrid(points=simple_pyntcloud.xyz, n_x=2, n_y=2, n_z=2, regular_bounding_box=False)
    voxelgrid.compute()

    feature_vector = voxelgrid.get_feature_vector(mode=mode)

    assert feature_vector.shape == (2, 2, 2)
github daavoo / pyntcloud / tests / unit / structures / test_voxelgrid_structures.py View on Github external
def test_regular_bounding_box_changes_the_shape_of_the_bounding_box(x, y, z):

    cloud = PyntCloud(pd.DataFrame(
        data={
            "x": np.array(x, dtype=np.float32),
            "y": np.array(y, dtype=np.float32),
            "z": np.array(z, dtype=np.float32)
    }))

    voxelgrid = VoxelGrid(points=cloud.xyz, n_x=2, n_y=2, n_z=2, regular_bounding_box=False)
    voxelgrid.compute()

    irregular_last_centroid = voxelgrid.voxel_centers[-1]

    voxelgrid = VoxelGrid(points=cloud.xyz, n_x=2, n_y=2, n_z=2)
    voxelgrid.compute()

    regular_last_centroid = voxelgrid.voxel_centers[-1]

    assert np.all(irregular_last_centroid <= regular_last_centroid)
github daavoo / pyntcloud / tests / unit / structures / test_voxelgrid_structures.py View on Github external
def test_sizes_override_number_of_voxels_per_axis(simple_pyntcloud):
    voxelgrid = VoxelGrid(points=simple_pyntcloud.xyz, size_x=0.2, size_y=0.2, size_z=0.2)
    voxelgrid.compute()
    assert np.all(voxelgrid.x_y_z == [5, 5, 5])
    assert voxelgrid.n_voxels == 125
    assert np.all(voxelgrid.voxel_n == [0, 0, 31, 62, 124, 124])
github daavoo / pyntcloud / tests / unit / structures / test_voxelgrid_structures.py View on Github external
def test_default_number_of_voxels_per_axis(simple_pyntcloud):
    voxelgrid = VoxelGrid(points=simple_pyntcloud.xyz)
    voxelgrid.compute()
    assert voxelgrid.n_voxels == 1
    assert np.all(voxelgrid.voxel_x == 0)
    assert np.all(voxelgrid.voxel_y == 0)
    assert np.all(voxelgrid.voxel_z == 0)
    assert np.all(voxelgrid.voxel_n == 0)
    feature_vector = voxelgrid.get_feature_vector()
    np.testing.assert_array_equal(feature_vector, np.array([[[1.]]]))
    neighbors = voxelgrid.get_voxel_neighbors(0)
    assert neighbors == [0]
github daavoo / pyntcloud / tests / unit / structures / test_voxelgrid_structures.py View on Github external
def test_regular_bounding_box_changes_the_shape_of_the_bounding_box(x, y, z):

    cloud = PyntCloud(pd.DataFrame(
        data={
            "x": np.array(x, dtype=np.float32),
            "y": np.array(y, dtype=np.float32),
            "z": np.array(z, dtype=np.float32)
    }))

    voxelgrid = VoxelGrid(points=cloud.xyz, n_x=2, n_y=2, n_z=2, regular_bounding_box=False)
    voxelgrid.compute()

    irregular_last_centroid = voxelgrid.voxel_centers[-1]

    voxelgrid = VoxelGrid(points=cloud.xyz, n_x=2, n_y=2, n_z=2)
    voxelgrid.compute()

    regular_last_centroid = voxelgrid.voxel_centers[-1]

    assert np.all(irregular_last_centroid <= regular_last_centroid)
github daavoo / pyntcloud / pyntcloud / ransac / samplers.py View on Github external
def __init__(self,
                 points, k, n_x=1, n_y=1, n_z=1, size_x=None, size_y=None, size_z=None, regular_bounding_box=True):
        super().__init__(points, k)
        self.voxelgrid = VoxelGrid(
            self.points, n_x=n_x, n_y=n_y, n_z=n_z, size_x=size_x, size_y=size_y, size_z=size_z,
            regular_bounding_box=regular_bounding_box)