CVB Python Multi-Camera Acquisition

Hi again,

Just to update on this, I have now been able to get the USB cameras streaming as desired.

We took delivery of 2 GigE cameras, which after some trial and error setup for PTP acquisition worked with the example below:

import datetime

import cvb
import time
import os

NUM_ACQUIRES = 0
NUM_FAILS = 0

ARRAY_1 = []
ARRAY_2 = []
TIMES_1 = []
TIMES_2 = []


class MyStreamHandler(cvb.MultiStreamHandler):

    def handle_async_wait_result(self, wait_result_list):
        print("handle_async_wait_result start")
        super().handle_async_wait_result(wait_result_list)
        image1, status1 = wait_result_list[0]
        image2, status2 = wait_result_list[1]
        global NUM_ACQUIRES
        global NUM_FAILS
        global ARRAY_1
        global TIMES_1
        global ARRAY_2
        global TIMES_2
        if status1 == cvb.WaitStatus.Ok and status2 == cvb.WaitStatus.Ok:
            NUM_ACQUIRES += 1
            ARRAY_1.append(image1)
            ARRAY_2.append(image2)
            TIMES_1.append(image1.raw_timestamp)
            TIMES_2.append(image2.raw_timestamp)
            print("====================================================")
            print("1 image: " + image1.__class__.__name__ + " " + str(image1) + " | Time: " + str(image1.raw_timestamp))
            print("2 image: " + image2.__class__.__name__ + " " + str(image2) + " | Time: " + str(image2.raw_timestamp))
        else:
            NUM_FAILS += 1


device1 = cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "GenICam.vin"), port=2)
device2 = cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "GenICam.vin"), port=3)

print("devices")

stream1 = device1.stream()
stream2 = device2.stream()

print("streams")

stream1.ring_buffer.change_count(200, 0)
stream2.ring_buffer.change_count(200, 0)

print("Setup done")

with MyStreamHandler([stream1, stream2]) as handler:
    print("pre-run")
    start_time = datetime.datetime.now()
    handler.run()
    time.sleep(1)
    handler.finish()
print("Took {} seconds".format(datetime.datetime.now() - start_time))

print(NUM_ACQUIRES)
print(NUM_FAILS)

I thought I’d try the USB cameras with the same changes made in the GenICam Browser, and they also worked.

The key parameters seemed to be setting Trigger Selector to Frame Start, and Trigger Mode to Off. We had Trigger Mode On from the examples that had been sent over previously.

Thanks,

Alex