This website is being translated through machine translation by a third-party service. Basler does not warrant the accuracy, reliability or timeliness of any information translated by this system and will not accept liability for loss or damage incurred as a result. Content that has not yet been translated appears in English. Switch to English version
Some cameras can return complex grab results consisting of multiple components. For example, Basler blaze cameras return a data stream that is composed of range, intensity, and confidence components. To access the individual components, you can use the IDataContainer class.
An IDataContainer can hold one or more components. You can obtain a container by calling IGrabResult::Container. You can then use the container to query for the number of components by calling Count. To retrieve a specific component, you can call Item(Int32). Each component in the container can be used to access the actual data, e.g., the range values, and its metadata. To iterate through the components, use an enumerator returned by GetEnumerator(). If you use a foreach loop as in the example below, this is called implicitly.
This sample shows how the enumerator is used implicitly.
// Retrieve a grab result and show all data components.
IGrabResult grabResult = camera.StreamGrabber.RetrieveResult( 5000, TimeoutHandling.ThrowException );
Console.WriteLine( "Found {0} components in the container.", grabResult.Container.Count );
// Display each component in a separate window.
int displayId = 1;
foreach( IDataComponent dataComponent in grabResult.Container )
{
if (dataComponent.IsValid)
{
Console.WriteLine( "Component type {0}", dataComponent.ComponentType.ToString() );
Console.WriteLine( "2D Size is {0}*{1} pixel", dataComponent.Width, dataComponent.Height );
Console.WriteLine( "Origins from ({0},{1})", dataComponent.OffsetX, dataComponent.OffsetY );
Console.WriteLine( "Pixel type is {0}", dataComponent.PixelTypeValue.ToString() );
Console.WriteLine( "Timestamp is {0}", dataComponent.Timestamp );
Console.WriteLine( "See image in display {0}:", displayId );
dataComponent.Display( displayId );
}
}