import cvb
def discovery():
devices = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins)
ret = {}
for discover in devices:
try:
device = cvb.DeviceFactory.open(discover.access_token, cvb.AcquisitionStack.GenTL)
dnm = device.node_maps["Device"]
name = dnm["DeviceVendorName"].value + " - " + dnm["DeviceModelName"].value
if name in ret: continue
print(dnm["DeviceVendorName"].value)
print(dnm["DeviceModelName"].value)
print(dnm["DeviceVersion"].value)
ret[name] = discover.access_token
except:
pass
return ret
class recording_GUI:
def __init__(self):
self.cams = discovery()
self.setup_streams()
def setup_streams(self):
self.streams = []
self.stream_names = []
for cam in self.cams:
with cvb.DeviceFactory.open(self.cams[cam], cvb.AcquisitionStack.GenTL) as device:
for i in range(device.stream_count):
self.streams.append(device.stream(cvb.ImageStream, i))
self.stream_names.append(cam + " " + str(i))
for stream in self.streams:
stream.engine_start()
stream.device_start()
if __name__ == "__main__":
x = recording_GUI()
Why is this error occurring and how do I solve it?
Hi @Chris
Thanks for responding. I’ve taken out the classes and I am still getting the same error as above.
This is the code without the classes:
import cvb
def discovery():
devices = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins)
ret = {}
for discover in devices:
try:
device = cvb.DeviceFactory.open(discover.access_token, cvb.AcquisitionStack.GenTL)
dnm = device.node_maps["Device"]
name = dnm["DeviceVendorName"].value + " - " + dnm["DeviceModelName"].value
if name in ret: continue
print(dnm["DeviceVendorName"].value)
print(dnm["DeviceModelName"].value)
print(dnm["DeviceVersion"].value)
ret[name] = discover.access_token
except:
pass
return ret
def setup_streams(cams):
streams = []
stream_names = []
for cam in cams:
with cvb.DeviceFactory.open(cams[cam], cvb.AcquisitionStack.GenTL) as device:
for i in range(device.stream_count):
streams.append(device.stream(cvb.ImageStream, i))
stream_names.append(cam + " " + str(i))
for stream in streams:
stream.engine_start()
stream.device_start()
if __name__ == "__main__":
cams = discovery()
setup_streams(cams)
So do I get this right, that even without creating an object of the GUI class, you are still getting the error?
I would have assumed, that the UI has its own UI thread context and as Py is a bit tricky with multiple threads, this was what might have caused an error.
But in your recently postet code this does not seem to be the case.
I think this would be the best way… start with the example and piece by piece abstract your way to where it fails, then we might be able to find out what causes this behaviour but for know I puzzled as well.
As mentioned bevore I will try this tomorrow, if you have any news bevore me let me know.
Hi @Chris,
I have tested the code from the migration guide and it works shown below:
import cvb
devices = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins)
with cvb.DeviceFactory.open(devices[0].access_token, cvb.AcquisitionStack.GenTL) as device:
streams = [device.stream(cvb.ImageStream, i) for i in range(device.stream_count)] # (1)
for stream in streams:
stream.engine_start() # (2)
for stream in streams:
stream.device_start() # (3)
for _ in range(10):
images = [stream.wait() for stream in streams]
try:
pass
finally:
for image, status, nodes in images:
with image:
pass
for stream in streams:
stream.device_abort()
for stream in streams:
stream.engine_abort()
So the best way would be to change this code to do what you like and test if it fails with every major change.
This is very likely a Python related “feature” and not a CVB Bug.