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 ItalaApiNET internal acquisition engine. At this point, the user is able to grab images by calling IDevice.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
device.StartAcquisition();

IImage image;
for (int i = 0; i < 100; i++)
{
  try
  {
    //Ask for an available image with a maximum timeout of 500ms
    image = device.GetNextImage(500);
  }
  catch (Execption e)
  {
    Console.WriteLine("No image available.");
    continue;
  }

  //If the image is incomplete due to errors, print some info and skip it.
  if (image.IsIncomplete)
  {
    Console.WriteLine("Incomplete image received.");
    Console.WriteLine("Bytes filled: " + image.BytesFilled);
    Console.WriteLine("Timestamp: " + image.Timestamp);
    continue;
  }

  //Display the image or do stuff with it..

  image.Dispose();
}

device.StopAcquisition();

//...

The image instance is received and accessed via the IImage interface. 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.