Downsample

Tip

Our webinar Getting your point cloud ready for your application partly covers Downsample.

Introduction

This article introduces a concept of downsampling, explains why it is valuable and demonstrates how to downsample a Zivid point cloud.

Zivid 2+ cameras use a sensor with 5 MP (2448 x 2048) to capture point clouds of a scene. The point cloud consists of XYZ (3D), RGB (color), and SNR data. The generated point cloud consists of 5 million points.

Zivid 2 cameras use a sensor with 2.3 MP (1944 x 1200) to capture point clouds of a scene. The point cloud consists of XYZ (3D), RGB (color), and SNR data. The generated point cloud consists of 2.3 million points.

Some applications do not require high-density point cloud data. Examples are box detection by fitting a plane to the box surface and CAD matching, where the object has distinct and easily identifiable features. In addition, this amount of data is often too large for machine vision algorithms to process with the speed required by the application. It is such applications where point cloud downsampling comes into play.

Downsampling in point cloud context is the reduction in spatial resolution while keeping the same 3D representation. It is typically used to transform the data to a more manageable size and thus reduce the storage and processing requirements.

There are two ways to downsample a point cloud with Zivid SDK:

  1. Via the setting Settings::Processing::Resampling (Resampling), which means it’s controlled via the capture settings.

  2. Via the API PointCloud::downsample.

In both cases the same operation is applied to the point cloud. Via the API version you can choose to downsample in-place or get a new point cloud instance with the downsampled data.

Problem

The size or resolution (density) of the point cloud is too large.

Solution

Downsample the Zivid point cloud to reduce its size and resolution.

Note

This article discusses downsampling applied during post-processing; for a hardware-based subsampling method that reduces resolution and, by that, also the acquisition and capture time, please refer to the Monochrome Capture.

Downsample API

Downsampling can be done in-place, which modifies the current point cloud.

Go to source

source

pointCloud.downsample(Zivid::PointCloud::Downsampling::by2x2);
Go to source

source

pointCloud.Downsample(Zivid.NET.PointCloud.Downsampling.By2x2);
Go to source

source

point_cloud.downsample(zivid.PointCloud.Downsampling.by2x2)

It is also possible to get the downsampled point cloud as a new point cloud instance, which does not alter the existing point cloud.

Go to source

source

auto downsampledPointCloud = pointCloud.downsampled(Zivid::PointCloud::Downsampling::by2x2);
Go to source

source

var downsampledPointCloud = pointCloud.Downsampled(Zivid.NET.PointCloud.Downsampling.By2x2);
Go to source

source

downsampled_point_cloud = point_cloud.downsampled(zivid.PointCloud.Downsampling.by2x2)

Zivid SDK supports the following downsampling rates: by2x2, by3x3, and by4x4, with the possibility to perform downsampling multiple times.

Note

Downsample API in Zivid SDK is fast because it is done on the GPU, in parallel, while the point cloud data is still on the GPU memory. Downsample implementations with third-party libraries are likely more time-consuming: CPU computations are much slower in general, and GPU computations require another copy. See Point Cloud Capture Process for more info.

If you are interested in the implementation, check out our downsampling code samples in C++, C#, Python, and MATLAB.

Tip

  • Use Downsample API in combination with transform and normals APIs for performance reasons because GPU performs all these computations while the point cloud data is still on the GPU memory.

  • For the fastest implementation, first, downsample the point cloud, then transform it.

To downsample a point cloud, you can run our code sample.

Sample: downsample.py

python /path/to/downsample.py --zdf-path /path/to/file.zdf

To learn more about how downsampling can be done and why it is not trivial, check out our reference article Downsampling Theory.

Version History

SDK

Changes

2.12.0

Downsampling can now also be done via Zivid::Settings::Resampling.

2.10.0

Monochrome Capture introduces a faster alternative to downsampling.

2.1.0

Downsampling API is added.