dwSensorCamera_readFrame() in different threads possible for multi-camera setup?

I am trying to implement a multi-camera setup with the Xavier. I have 4 cameras connected to it. I also referred to samples/sensors/camera/camera_multiple_gmsl/main.cpp.

The sample suggests to call dwSensorCamera_readFrame() in the same thread. (dwSensorCamera_readFrame() is called for each camera sibling ID in a simple ‘for’ loop). I was wondering if it was possible to have a separate thread for each camera to read frames. When I tried to implement such an architecture, I ended up with DW_FAILURE errors when I was trying to call dwSensorCamera_returnFrame(). It eventually led to DW_TIMEOUT in dwSensorCamera_readFrame() since the frames failed to be returned successfully.

Hi @hitman2710,

May I know which return value mentioned in dwSensorCamera_returnFrame() API docs you see?

Do you see error messages like “DW Error DW_XXXXXXX_XXXXX executing DW function:
dwSensorCamera_returnFrame”?

I am surprised to see that the dwSensorCamera_returnFrame() API does not return a DW_FAILURE according to the docs. I encounter a “DW_FAILURE” when I call dwSensorCamera_returnFrame(). (Error code 33)

If it helps, my camera params are :
“camera-type=ar0231-rccb-bae-sf3324,”
“camera-group=a,”
“camera-count=4,”
“camera-mask=1111”
and I am using Drive Software 9.

When I try to read/return frames on the same thread for all 4 cameras, it seems to be working. However, I would still like to have a separate thread for each camera.

DriveWorks functions are thread-unsafe unless stated otherwise (see “Memory Management Policies and Multithreading”). Try synchronizing so that only a single call related to the dwSensorObject is in flight at any time.

We will check if the docs need to be improved and get back to you here. Thanks!

Hi @hitman2710,

Could you provide the complete log of the issue on your application here? We would like to check if any message from DriveWorks. Thanks!

Hi @hitman2710,

Please provide your source code for our repro and then we will see how to improve our docs. Thanks!