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 itala.itala.IImage.get_next_image() . 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.start_acquisition()

for (int i in range(100)):
  try:
    # Ask for an available image with a maximum timeout of 500ms
    image = device.get_next_image(500)
  except:
    print("No image available.")
    continue

  # If the image is incomplete due to errors, print some info and skip it.
  if (image.is_incomplete)
    print("Incomplete image received.")
    print("Bytes filled: " + str(image.bytes_filled))
    print("Timestamp: " + str(image.timestamp))
    continue

  # Display the image or do stuff with it..

  image.dispose();

device.stop_acquisition();

# ...

The image instance is received and accessed via its class itala.itala.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.

When the data of the image is needed, ItalaApi offers a buffer object needed to convert the data obtained from the API to python use. For example when a defective pixel operation is needed the steps to follow are:

dark_image = device.get_next_image(500)
buffer = dark_image.get_data()
buff = itala.buffer.frompointer(buffer)
mono8_detection.accumulate_dark(buff.cast())
dark_image.dispose()

If you want to save to file an image you can follow these spets (pixel format mono 8):

import ctypes
import cv2

# ...

height = dark_image.height
width = dark_image.width
size = width * height
p = (ctypes.c_uint8 * size).from_address(int(buffer))
nparray = np.ctypeslib.as_array(p)
cvimage = nparray.reshape((height, width))
cv2.imwrite("image.jpg", cvimage)

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 itala.itala.IDevice interface.