With Common Vision Blox 13.3 new image and data acquisition interfaces have been introduced. The GenTL interface now also supports acquisition of multiple streams from one device, acquisition of structured data streams that contain multiple logical parts (enabling the acquisition of 3D point clouds directly from devices that support this) and acquisition into user-specified destination buffers. A detailed description how to acquire images and point clouds can be found in the document 3rd Generation Acquisition Interfaces. If you are still using the CVB vin driver and like to migrate you code to the up-to-date GenTL stack, you will find a step-by-step guide for all supported programming languages in the document Migration Guide for the Acquisition Stacks.
The Common Vision Blox SDK is provided for three programming languages. Further information can be found under the following links:
In general the pixel access depends on the underlying image layout. Therefore CVB provides the fast linear access for images with a linear memory representation and a slower VPAT access for all other memory layouts. Detailed information about the memory layouts can be found in the manual for the ImageManager. In C++ and python a convenient image access is provided by CVB which is independent from the memory layout.
In C++ the most convenient way to access pixel values is using Cvb::Vist(). Cvb::Vist() accepts as input an image plane and a lambda function or a function object where the operation to be executed on the image pixel is impelemented. The only pre-requisite is, that the lambda function can deal with a Cvb::Block object as shown in the example below.
A detailed description of Cvb::Vist() and more code examples can be found here.
#include <cvb/block.hpp>
auto image = ...;
// pixel access using a lamda function and Cvb::Visit()
Cvb::Visit([](auto block)
{
// loop over whole image
for (int y = 0; y < block.Height(); ++y) {
for (int x = 0; x < block.Width(); ++x) {
block(x, y) /= 2; // divide pixel value by 2
}
}
}
, image->Plane(0));
(1) Always use the fast linear access, if the image layout allows it.
(2) If the linear access is not possible, use the slower VPAT access. Check the data type of your plane with plane.DataType.BytesPerPixel and choose the appropriate type of the VPAT access.
(3) It is highly recommended to store image properties like height and width to separate variables, as they are not stored to variables in the Image class. Instead a function is called on the image getting the variables.
(1) First you convert your image in a numpy array using cvb.as_array(). If you like to modify your image values, you need to set the copy flag to False. In this case the data is mapped and you can work directly on the array.
(2) But attention: The mapping is not supported for all image layouts! Therefore you have to check, whether the mapping was sucessful. If it was not sucessful, set the copy flag to False. In this case, you work on the copied data and not on the original image.
(3) Then you can modify your image pixels using the numpy array.
This interface allows to register callback functions for events like disconnect/reconnect or events generated by the device. In case such an event carries additional data, it is passed to the callback function.