Image grabbing#
The image retrieval process starts within the camera. The device reads out the image data collected from the sensor and transfers it via GigE Vision to the host. This process is called acquisition. The acquisition can go on for a given number of frames or it can continue indefinitely until manually stopped. When images are received by the host, they’re collected in a queue managed by the ItalaApi internal acquisition engine. At this point, the user is able to grab images by calling GetNextImage
. This function pops the first available image (if any) from the queue and delivers it to the client code.
Warning
The client code is responsible for the image instance lifetime. The client code must release the grabbed image when it’s no longer required, so that its memory can be reused for grabbing.
//...
//Start the acquisition process on the camera
pDevice->StartAcquisition();
Itala::IImage* pImage = 0;
for (int i = 0; i < 100; i++)
{
try
{
//Ask for an available image with a maximum timeout of 500ms
pImage = pDevice->GetNextImage(500);
}
catch (GenICam::TimeoutException &e)
{
std::cout << "No image available." << std::endl;
continue;
}
//If the image is incomplete due to errors, print some info and skip it.
if (pImage->IsIncomplete())
{
std::cout << "Incomplete image received." << std::endl;
std::cout << "Bytes filled: " << pImage->GetBytesFilled() << std::endl;
std::cout << "Timestamp: " << pImage->GetTimestamp() << std::endl;
continue;
}
//Display the image or do stuff with it..
pImage->Dispose();
pImage = nullptr;
}
pDevice->StopAcquisition();
//...
The image instance is received and accessed via its interface IImage
. It contains all the necessary informations to be displayed or processed via third party tools, e.g. its width, height, format, size and data pointer.
Warning
The created device instances are automatically configured to use the filter driver and packet resend functionalities for a more reliable and efficient acquisition. Make sure the filter driver component is enabled on the NIC the device is connected to. Both functionalities can be found and disabled on the DataStream nodemap provided by the IDevice
interface.