GrabTrigger#

from itala import itala

ACQUIRE_COUNT = 5

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
print("Configure trigger mode..")

# Select the "action" that must be performed when the trigger is received.
trigger_selector_node = nodemap.TriggerSelector
if(not itala.is_writable(trigger_selector_node)):
    print("Unable to select the trigger type. Aborting.")
    exit(1)
trigger_selector_node.from_string("FrameBurstStart")

# Set the source of the trigger. In this case, a software trigger (which is
# just a command) is used.
trigger_source_node = nodemap.TriggerSource
if(not itala.is_writable(trigger_selector_node)):
    print("Unable to configure the trigger. Aborting.")
    exit(1)
original_trigger_source = trigger_source_node.get_int_value()
trigger_source_node.from_string("Software")

# Finally, enable the trigger mode.
trigger_mode_node = nodemap.TriggerMode
if(not itala.is_writable(trigger_selector_node)):
    print("Unable to configure the trigger. Aborting.")
    exit(1)
original_trigger_mode = trigger_mode_node.get_int_value()
trigger_mode_node.from_string("On")

device.start_acquisition()
print("Acquisition started.")

trigger_software_node = nodemap.TriggerSoftware
if(not itala.is_writable(trigger_selector_node)):
    print("Unable to send software trigger command. Aborting.")
    exit(1)
for i in range(ACQUIRE_COUNT):
    trigger_software_node.execute()
    print("\tSoftware trigger sent, image acquired.")
    input("\tPress Enter to grab the acquired image.")

    image = device.get_next_image(1000)
    if(image.is_incomplete):
        print("\n\tImage "+str(image.frame_id)+ " is incomplete.")
        print("\t\tBytes filled: "+str(image.bytes_filled)+"/"+str(image.payload_size))
        print("\t\tTimestamp: "+str(image.timestamp))
    else:
        print("\n\tImage "+str(image.frame_id)+" grabbed.")

    # DO SOMETHING WITH THE IMAGE
        
    image.dispose()

device.stop_acquisition()

# Restore the original values
trigger_source_node.set_int_value(original_trigger_source)
trigger_mode_node.set_int_value(original_trigger_mode)

device.dispose()
print("Device instance disposed.")

system.dispose()
print("System instance disposed")