Point Cloud Capture Process
The capture API returns at some moment in time after the camera completes capturing raw images and before or at the moment the point cloud processing is done. This depends on the GPU (vendor and driver). Therefore, after the capture API returns, the point cloud processing might still be running in the background.
Use recommended hardware to minimize computation time.
const auto frame = camera.capture(settings);
using(var frame = camera.Capture(settings))
with camera.capture(settings) as frame:
The API to get the point cloud always returns a point cloud object right away. The point cloud object holds a handle to the point cloud data in GPU memory. Point cloud processing might also still be running in the background at this point.
const auto pointCloud = frame.pointCloud();
var pointCloud = frame.PointCloud;
point_cloud = frame.point_cloud()
We need to call the API to copy the point cloud from the GPU memory to the CPU memory. The copy function will block and wait until the data is available before copying it. When the function returns, the data is available and ready for use in CPU memory.
Even if using a CPU with an integrated GPU, the data is copied to a different area on the same main RAM.
const auto data = pointCloud.copyData<Zivid::PointXYZColorRGBA>();
var pointCloudData = pointCloud.CopyPointsXYZColorsRGBA();
xyz = point_cloud.copy_data("xyz") rgba = point_cloud.copy_data("rgba")
When the point cloud is available on the CPU memory, we can utilize it in our machine vision application.
Operations on the point cloud in Zivid SDK, e.g., Downsample, Transform, and Normals, are computed on the GPU while the point cloud is still in GPU memory. In addition, by downsampling on the GPU with Zivid API, there is also less data to copy to the CPU. Therefore, it is beneficial to use Zivid SDK for these operations for performance reasons. Implementing these point cloud operations with a third-party library is likely more time-consuming. In general, CPU computations are much slower. In addition, GPU computations require another copy from the CPU memory back to the GPU memory because a Zivid SDK user cannot access the GPU memory used by Zivid SDK.