Some devices may be able to provide multiple pieces of data in a single data streams. For example, there could be a camera that sends two pieces of data, one being a color image and the seconds some metadata such as timestamp and location. As these two pieces of information are different but related (unlike a camera sending two data streams), these will be presented as a single Cvb::Composite
object.
while(true)
{
std::tie(composite, status, nodeMaps) = stream->Wait();
for (int i = 0; i < composite->ItemCount(); i++)
{
auto component = composite->ItemAt(i);
if (auto image = get_if<ImagePtr>(&component))
{
}
else if (auto pointCloud = get_if<PointCloudPtr>(&component))
{
}
}
}
stream->Abort();
static std::vector< DiscoveryInformation > Discover()
static std::shared_ptr< T > Open(const String &provider, AcquisitionStack acquisitionStack=AcquisitionStack::PreferVin)
std::shared_ptr< Composite > CompositePtr
{
{
while(true) {
using (var composite = stream.Wait(out status))
{
foreach (var part in composite)
{
if (part.GetType() == typeof(
Image)) {
}
}
}
}
}
stream.Abort();
}
}
static Device Open(DiscoveryInformation info, AcquisitionStack acquisitionStack=AcquisitionStack.PreferVin)
static DiscoveryInformationList Discover()
static PointCloud FromHandle(IntPtr handle, ShareObject doShare)
cvbbool_t ShareObject(OBJ Object)
import cvb
stream.start()
while True:
composite, status, node_maps = stream.wait()
with composite:
for part in composite:
stream.abort()
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
List[cvb.DiscoveryInformation] discover_from_root(int flags=cvb.DiscoverFlags.FindAll, int time_span=300)
Note: Error handling has been omitted from the above example.
Note: In this example, we treat each component as potentially being a different type on each frame. In reality, for a specific camera model, the component type at each index should not change type (i.e. item 1 is always the image, item 2 is the metadata, etc).
- The device and stream are opened as normal. To ensure that all components can be received, the stream must be of type
Cvb::CompositeStream
.
- The composite is read from the stream in the same manner as a normal image.
- Each component of a
Cvb::Composite
has a specified type, Cvb::Image
, Cvb::PointCloud
, etc. The type of the component is checked to determine how to process it.