Common Vision Blox 15.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Friends Modules Pages
Image Processing - Reinterpreting Images as PFNC Buffer

Attention
Reinterpreting Images as PFNC Buffers is not supported in the Python API.

By default, the CVB acquisition attempts to process the received data as an Image or Point Cloud as specified by the stream type. If this is not possible (e.g. due to unsupported/invalid data formats), no Cvb::Image or Cvb::PointCloud will be returned. To access this data, the underlying buffer can be read and parsed instead using a Cvb::CompositeStream.

auto devices = Cvb::DeviceFactory::Discover(Cvb::DiscoverFlags::IgnoreVins);
auto device = Cvb::DeviceFactory::Open<Cvb::GeniCamDevice>(devices[0].AccessToken(), Cvb::AcquisitionStack::GenTL);
auto stream = device->Stream<Cvb::CompositeStream>(); // default: index = 0 (1)
stream->Start();
while(true)
{
Cvb::CompositePtr composite;
std::tie(composite, status, nodeMaps) = stream->Wait(); // (2)
auto handle = Cvb::visit([](auto&& element) { return element->Handle(); }, cvb_composite->ItemAt(0)); // (3)
auto buffer = Cvb::PFNCBuffer::FromHandle(Cvb::HandleGuard<Cvb::BufferBase>(handle)); // (4)
// Process buffer
}
stream->Abort();
void Start() override
static std::vector< DiscoveryInformation > Discover()
static std::shared_ptr< T > Open(const String &provider, AcquisitionStack acquisitionStack=AcquisitionStack::PreferVin)
static PFNCBufferPtr FromHandle(HandleGuard< BufferBase > &&guard)
auto visit(VISITOR &&visitor, VARIANT &&var) -> decltype(visitor(get< 0 >(var)))
WaitStatus
std::shared_ptr< Composite > CompositePtr

using (var devices = DeviceFactory.Discover(DiscoverFlags.IgnoreVins))
{
using (var device = (GenICamDevice)DeviceFactory.Open(devices[0], AcquisitionStack.GenTL))
{
var stream = device.GetStream<CompositeStream>(0); // (1)
stream.Start();
while(true) {
WaitStatus status;
using (var composite = stream.Wait(out status)) // (2)
{
var handle = composite[0].Handle(); // (3)
var buffer = PFNCBuffer.FromHandle(handle, ShareObject.No) // (4)
// Process buffer
}
}
stream.Abort();
}
}
static Device Open(DiscoveryInformation info, AcquisitionStack acquisitionStack=AcquisitionStack.PreferVin)
static DiscoveryInformationList Discover()
cvbbool_t ShareObject(OBJ Object)

Note: Error handling has been omitted from the above example.

  1. The device and stream is opened per normal. It is recommended to use a Cvb::CompositeStream but any stream type can be accessed as a buffer.
  2. The composite is read from the stream in the same manner as a normal image.
  3. The handle to the underlying object is retrieved.
  4. A Cvb::PFNCBuffer view is created on the underlying object, allowing the data to be read out from it.