from itala import itala
def OnPayloadSizeChanged(node):
print("\tOnPayloadSizeChanged function called.")
print("\tPayloadSize node changed. New value is " + str(node.value) + "\n")
system = itala.create_system()
devices_info = system.enumerate_devices(500)
if(len(devices_info) == 0):
print("No devices found. Example canceled.")
exit(1)
if(devices_info[0].access_status != itala.DeviceAccessStatus_AvailableReadWrite):
print("Target device is unaccessible in RW mode. Example cancelled.")
exit(1)
device = system.create_device(devices_info[0])
print("First device initialized.")
nodemap = device.node_map
# Get the PixelFormat node and set its value to Mono8 for example
# purposes. The original value is saved and then restored at the end of
# the program.
pixel_format_node = nodemap.PixelFormat
if(not itala.is_writable(pixel_format_node)):
print("Unable to configure the pixel format. Aborting.")
exit(1)
original_pixel_format = pixel_format_node.get_int_value()
pixel_format_node.from_string("Mono8")
# Get PayloadSize node
payload_size_node = nodemap.PayloadSize
if(not itala.is_readable(payload_size_node)):
print("Unable to get the image payload size. Aborting.")
exit(1)
print("\nThe payload sixe is " + str(payload_size_node.value) + " with Mono8 format.")
# Register the callback to the PayloadSize node so that when a
# change in its value occurs, the function is executed
callback_handle = itala.register(payload_size_node.node, OnPayloadSizeChanged)
print("OnPayloadSizeChanged function registered to PayloadSize node.")
print("Setting pixel format to Mono12p..")
# Set the pixel format to Mono12p. At this point, the callback gets
# automatically executed by GenApi since the PayloadSize feature
# is changed after the new PixelFormat.
pixel_format_node.from_string("Mono12p")
# Deregister the callback function when done.
itala.deregister(callback_handle)
# Restore the original pixel format value.
pixel_format_node.set_int_value= original_pixel_format
device.dispose()
print("Device instance disposed.")
system.dispose()
print("Device instance disposed.")