Zivid SDK 2.0 introduces major changes to the capture settings. The most significant change is that a single Zivid::Settings object now contains complete settings for any capture task, including multi-acquisition capture (HDR). This is in contrast to SDK 1.x, in which a HDR capture was represented by a list of Settingsobjects (or a list of Frames that could be merged at a later time).
In SDK 2.0, a Settings object is divided into two main parts:
Zivid::Settings::Acquisitions: A list of Zivid::Settings::Acquisition, which specify the parameters of image-acquisition on the Zivid camera itself. Each Acquisition includes settings such as camera aperture (f-number) and projector brightness.
Zivid::Settings::Processing: Specifies the parameters of the point-cloud processing occurring on the PC GPU, based on the images acquired on the camera. This includes filtering settings and color settings.
Secondly, the Settings is no longer given to the camera before capture as a separate operation. In SDK 2.0, settings are passed as an argument to Zivid::Camera::capture(Zivid::Settings). The user may specify as few or as many parts of Zivid::Settings as desired. The remaining camera-model appropriate defaults will be applied at the time of calling capture().
Lastly, 2D-capture is performed by passing a Zivid::Settings2D to the same capture function,Zivid::Camera::capture(Settings2D). The new Settings2D is structured similarly to the new Settings.
In SDK 1, a HDR capture was specified by constructing a list of Settings. In SDK 2.0, everything is contained in a single Settings, and a HDR capture is specified by letting it contain multiple Zivid::Settings::Acquisition. These may be created at the time of constructing the Settings, or added later with e.g. settings.acquisitions().emplaceBack(acquisition). To see an example, see CaptureHDRCompleteSettings sample.
The following is a summary of the relation between members of old settings and the members of the new Zivid::Settings::Acquisition:
This setting is removed.
*The setting to control the Iris/Aperture is changed. The f-number unit is introduced. To change your iris values with equivalent aperture f-numbers, check out the IrisToAperture conversion list below Note: If the file doesn’t load in your browser, click the download icon.
A new filter Contrast Distortion is introduced, Zivid::Settings::Processing::Experimental::ContrastDistortion. Note: This filter does not have anything to do with the old Contrast value.
Filters are applied after acquisitions and are organized under Zivid::Settings::Processing::Filters. The following shows how filters have moved, and in some cases changed.
This filter is removed. It is always enabled and not possible to disable.
This filter is replaced with a new filter - Zivid::Settings::Processing::Filters::Noise::Removal *
*The contrast filter removed points based on the contrast value threshold. The noise filter removes points based on the SNR value threshold. SNR and contrast values are computed differently, and the two filters are therefore different; Consider the noise filter as a contrast filter improvement. To achieve similar results, different threshold values must be applied. Similar value to a Contrast threshold of 3 is the Noise threshold value of 7.
Color balance is improved with SDK 2.0. Color balance settings now only affects the colors of the point cloud, and has no effect on the computed XYZ point coordinates.
auto camera = zivid.connectCamera(Zivid::Settings("Frame01.yml"));
const auto settings = Zivid::Settings("Settings.yml");
The main change here is that the input file contains settings for all acquisitions. Previously we had one file per Frame. Now we have one file with everything. Note also the name change from Frame to Acquisition in this context.
Zivid::Settings2D::Acquisition (Acquisition settings - former Frame settings)
The changes made on Zivid::Settings2D::Acquisition are equivalent to the changes made on Zivid::Settings::Acquisition, see Acquisition Settings (3D). Note that 2D settings allow only one acquisition (multi acquisition 2D HDR is not possible).
Note that we don’t support filters for 2D settings.
Color balance is now added for 2D settings. Configuring Zivid::Settings2D::Processing::Color::Balance is the same as configuring Zivid::Settings::Processing::Color::Balance, see Color Balance (3D).
3D - Single Acquisition
The new Zivid::Camera::capture() API always takes settings as input.
auto frame = camera.capture();
auto frame = camera.capture(settings);
3D - Multi Acquisition HDR
Whether the capture is a single acquisition or multi-acquisition (HDR) is given by the input parameter settings. The call signature is always Zivid::Camera::capture(Zivid::Settings), regardless of whether it is single acquisition or HDR.
The API to capture 2D image doesn’t have 2D in capture, i.e. it is Zivid::Camera::capture() instead of Zivid::Camera::capture2D(). Whether Zivid::Camera::capture() produces 2D or 3D is given by the input parameter, Zivid::Settings2D or Zivid::Settings.
auto frame2D = camera.capture2D(settings2D);
auto image = frame2D.image<Zivid::RGBA8>();
auto frame2D = camera.capture(settings2D);
auto image = frame2D.imageRGBA();
The captured image can be read via frame2D.imageRGBA()as opposed to frame2D.image<Zivid::RGBA8>(). The image is always a two-dimensional array of RGBA pixels with 8-bit red, green, blue and alpha channels.
Before SDK 2.0 the point cloud was accessed via Zivid::Frame::getPointCloud(). This API copied all data from GPU to system memory in a 1200x1920x7 matrix, see Point Cloud. In SDK 2.0 you first get a handle to the point cloud data on the GPU through Zivid::Frame::pointCloud(). This call does not perform any copying from GPU memory. Then you can selectively copy data based on what is required. You can even copy directly into your own pre-allocated memory.
A new point-cloud quality value has also been introduced: Signal-to-Noise-Ratio (SNR). This replaces the old Contrast value, and is always a non-negative non-NaN number.
Complete list of new output data-formats and how to copy them from the GPU:
Functions for copying from GPU
Data per pixel
Total data copied
Functions for copying from GPU
Data per pixel
Total data copied
Copy selected data from GPU to system memory (Zivid-allocated)
Even if a user is only concerned about the XYZ coordinates of the point cloud they would previously need to call Zivid::Frame::getPointCloud(), which would copy all data to the system memory. In SDK 2.0 this may be achieved faster by only calling PointCloud::copyPointsXYZ(). Similarly, consider a use case where we only need the RGB colors from the point cloud:
auto rgba = frame.pointCloud().copyColorsRGBA();
auto *dataPtr = const_cast<void *>(static_cast<const void *>(rgba.data()));
cv::Mat rgba(rgba.height(), rgba.width(), CV_8UC4, dataPtr);
Line 1: Copy XYZ + RGBA + Contrast data from GPU to system memory.
Line 3: Allocate OpenCV matrix with an appropriate size to hold just the RGB data.
Line 8-17: Selectively copy RGB data from one part of system memory to another.
Line 1: Colors are copied from the GPU and into a Zivid::Array2D<Zivid::ColorRGBA>, which takes ownership of the data.
Line 2: Cast the data pointer as a void*, since this is what the OpenCV matrix constructor requires.
Line 3: We wrap this block of data in an OpenCV matrix. This is possible since the layout of Zivid::ColorRGBA exactly matches the layout of CV_8UC4. No copying occurs in this step.
Copy selected data from GPU to system memory (user-allocated)
In the above example, ownership of the data was held by the returned Zivid::Array2D<> objects. Alternatively, the user may provide a pre-allocated memory buffer to Zivid::PointCloud::copyData(dataPtr), and the type of dataPtr defines what shall be copied (PointXYZ*, ColorRGBA*, etc).
Now let us look at the exact same use case as above. However, this time we let OpenCV allocate the necessary storage, and then we ask the Zivid API to copy data directly from the GPU into this memory location:
auto intrinsics = Zivid::Experimental::Calibration::intrinsics(camera);
The member functions on Camera that used to get firmware version, model name, etc. have been removed. Information about the camera is now organized under Zivid::CameraInfo. This is a member of Zivid::Camera, accessed via Zivid::Camera::info().
auto firmwareVersion = camera.firmwareVersion();
auto firmwareVersion = camera.info().firmwareVersion();
auto modelName = camera.modelName();
auto modelName = camera.info().modelName();
auto majorRevision = camera.revision().majorRevision();
auto minorRevision = camera.revision().minorRevision();
auto majorRevision = camera.info().revision().major();
auto minorRevision = camera.info().revision().minor();
auto serialNumber = camera.serialNumber();
auto serialNumber = camera.info().serialNumber();
auto maxDataSize = camera.userDataMaxSizeBytes();
auto maxDataSize = camera.info().userData().maxSizeBytes().value();