Problem with SDK function ArduCam_open(), returns USB_CAMERA_USB_CREATE_ERROR

Hi,

I’m currently working on a project with the AR-0135 global shutter camera using a Raspberry Pi module, and sometimes, but not always, having trouble connecting to the camera.

Used hardware:

Camera: AR0135-C
USB2 camera shield: UC-391 Rev. D
Platform: Raspberry Pi 3B+

Used software:

Arducam Software SDK and API for C/C++
Arducam config file: AR0134_960p_Color.yml
openCV
QT framework (for writing the application)

I have basically copied the code from the Streaming_demo cpp example but divided it into a couple of QT classes.

svArduCam class:

  • Scans for cameras
  • Reads the config file
  • Opens the camera
  • On successful camera open, creates one capture thread and one read thread

svArduCamCapture class:

  • The capture thread

svArduCamRead class:

  • The read thread

I am sometimes (but only sometimes) having trouble opening the camera with the SDK function ArduCam_open function (or ArduCam_autoopen, same symptom).
When it actually opens, everything is working as expected and I am successfully streaming and displaying images, but sometimes the ArduCam_open function fails and returns USB_CAMERA_USB_CREATE_ERROR (0xFF01) and I just can’t figure out why.
Just before opening the camera I succesfully scans for avaialable cameras and this always succeeds. If I compile and run the Cpp Streaming Demo code this problem doesn’t seem to occur. But the thing is I haven’t changed any essential parts of the demo code, so I really can’t find any differences.

I realize that the issue very well still might be in my code but before ripping any more of my hair off :
Is there any known issues with the used hardware described above or the software SDK that can explain this problem? Could it be som sort of timing problem?
I downloaded the SDK in feb 2019 (the project hase been on hold for a while) and I can see that some updates have been made.

Greatful for any tips or insights.
I can post the relevant code if helpful.

Cheers.

Hi,

Thanks for your business. Don’t worry and I will try my best to help you.

Without power off, Can you try open it many times?

Hi,

Thanks for your reply.
I have now tested to try to open the camera several times (up to 10) by calling ArduCam_autoopen() in a loop with 2s delay (sleep) between each try and breaking the loop on success.
When open succeeds it is always on the first try, when it fails all 10 tries fails.

Hi again,

Might have solved this issue but more on an empirical basis. I now create the svArduCam instance (that’s the class responsible for opening the camera) the first thing I do in main(). So this is done before entering Qt:s event loop. This seems to have a positive effect. The camera now seems to open in a more stable way, but I will need testing during a longer period to take this for certain. One thought is that the event loop execution might interrupt the ArduCam_autoopen() execution and hence make this fail sometimes. But I don’t think the Qt:s event loop execution works that way, I don’t think it interrupts method calls in the same thread. So I’m still a bit puzzled. It would prefer to actually understand what happens so if anyone has some insights please share.

Cheers.

Hi @per@subvision.se ,

There is a known issue here that requires a delay of about two seconds between scanning and opening.

I don’t know much about qt, I can’t help you diagnose the problem through your description.

Hi again,

Yes I have read about the needed 2s delay between scanning and opening and have implemented this delay with a thread sleep just as in the demo code. I have also tried longer delays. Is ArduCam_autoopen() threadsafe, or can an interruption by a another thread cause problems?

Hi,

Can you share part of your code? I need more information to find the problem.