I have five cameras.
I took the multiple camera example and here are the errors:
c:\Users\tonya\OneDrive - Viewray Systems Inc\Documents\Python>python multipleDevices.py
===Connected to 18443010B1C8690F00
MXID: 18443010B1C8690F00
Num of cameras: 1
USB speed: UsbSpeed.SUPER
Board name: OAK-1
←[31mF: [global] [ 0] [ThreadN] dispatcherResponseServe:928 no request for this response: XLINK_READ_REL_RESP 1
←[0m
[18443010B1C8690F00] [1.1.1.1] [1731631485.297] [host] [warning] Device crashed, but no crash dump could be extracted.
Then I have written a few of my own codes to try to talk to multiple cameras. Here is the code:
#!/usr/bin/env python3
#
# Show image from two cameras
#
import cv2
import depthai as dai
# List all the cameras available
idev = 0
for device in dai.Device.getAllAvailableDevices():
print(f"{device.name} {device.getMxId()} {device.state}")
idev = idev + 1
# Need at least two cameras.
if idev < 2:
print( "Found {idev} cameras. Need at least two cameras." )
# Create pipeline
pipeline1 = dai.Pipeline()
pipeline2 = dai.Pipeline()
# Define source and output
camRgb1 = pipeline1.create(dai.node.ColorCamera)
camRgb2 = pipeline2.create(dai.node.ColorCamera)
xoutVideo1 = pipeline1.create(dai.node.XLinkOut)
xoutVideo2 = pipeline2.create(dai.node.XLinkOut)
xoutVideo1.setStreamName("video1")
xoutVideo2.setStreamName("video2")
# Properties
camRgb1.setBoardSocket(dai.CameraBoardSocket.CAM_A)
camRgb1.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camRgb1.setVideoSize(1920, 1080)
camRgb2.setBoardSocket(dai.CameraBoardSocket.CAM_A)
camRgb2.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camRgb2.setVideoSize(1920, 1080)
xoutVideo1.input.setBlocking(False)
xoutVideo2.input.setQueueSize(1)
xoutVideo1.input.setBlocking(False)
xoutVideo2.input.setQueueSize(1)
# Linking
camRgb1.video.link(xoutVideo1.input)
camRgb2.video.link(xoutVideo2.input)
# Connect to device and start pipeline
camera = dai.Device.getAllAvailableDevices()
device_info1 = dai.DeviceInfo(camera[0].getMxId()) # MXID
device_info2 = dai.DeviceInfo(camera[1].getMxId())
with dai.Device(pipeline1, device_info1) as device1:
with dai.Device(pipeline2, device_info2) as device2:
video1 = device1.getOutputQueue(name="video1", maxSize=1, blocking=False)
video2 = device2.getOutputQueue(name="video2", maxSize=1, blocking=False)
cnt = 0
while True:
videoIn1 = video1.get()
videoIn2 = video2.get()
# Get BGR frame from NV12 encoded video frame to show with opencv
# Visualizing the frame on slower hosts might have overhead
cv2.imshow("video1", videoIn1.getCvFrame())
cv2.imshow("video2", videoIn2.getCvFrame())
if cnt == 0:
cv2.resizeWindow( "video1", 200, 200 )
cv2.resizeWindow( "video2", 200, 200 )
cv2.moveWindow( "video1", 100, 100 )
cv2.moveWindow( "video2", 300, 100 )
cnt = cnt + 1
if cv2.waitKey(100) == ord('q'):
break
I did see two windows come up. Here are the error messages:
c:\Users\tonya\OneDrive - Viewray Systems Inc\Documents\Python>python vid2.py
1.1.1.1 18443010B1C8690F00 XLinkDeviceState.X_LINK_UNBOOTED
1.1.1.2 18443010A175680F00 XLinkDeviceState.X_LINK_UNBOOTED
1.1.3 18443010E109690F00 XLinkDeviceState.X_LINK_UNBOOTED
1.1.4 1844301081D1650F00 XLinkDeviceState.X_LINK_UNBOOTED
1.1.2 1844301081D4650F00 XLinkDeviceState.X_LINK_UNBOOTED
c:\Users\tonya\OneDrive - Viewray Systems Inc\Documents\Python\vid2.py:58: DeprecationWarning: Use constructor taking 'UsbSpeed' instead
with dai.Device(pipeline1, device_info1) as device1:
c:\Users\tonya\OneDrive - Viewray Systems Inc\Documents\Python\vid2.py:59: DeprecationWarning: Use constructor taking 'UsbSpeed' instead
with dai.Device(pipeline2, device_info2) as device2:
←[31mF: [global] [ 0] [ThreadN] dispatcherResponseServe:928 no request for this response: XLINK_READ_REL_RESP 1
←[0m
[18443010A175680F00] [1.1.1.2] [1731631676.974] [host] [warning] Device crashed, but no crash dump could be extracted.
Traceback (most recent call last):
File "c:\Users\tonya\OneDrive - Viewray Systems Inc\Documents\Python\vid2.py", line 68, in <module>
videoIn2 = video2.get()
^^^^^^^^^^^^
RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'video2' (X_LINK_ERROR)'