- March 19, 2020 at 9:41 am #21450AnonymousInactive
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.
USB2 camera shield: UC-391 Rev. D
Platform: Raspberry Pi 3B+
Arducam Software SDK and API for C/C++
Arducam config file: AR0134_960p_Color.yml
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.
– Scans for cameras
– Reads the config file
– Opens the camera
– On successful camera open, creates one capture thread and one read thread
– The capture thread
– 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.
- March 19, 2020 at 5:40 pm #21451binKeymaster
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?
- March 20, 2020 at 1:31 am #21455AnonymousInactive
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.
- April 3, 2020 at 1:26 am #21667AnonymousInactive
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.
- April 6, 2020 at 5:52 pm #21680
- April 7, 2020 at 1:01 am #21684AnonymousInactive
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?
- April 25, 2020 at 6:03 pm #22008wongModerator
Can you share part of your code? I need more information to find the problem.
- You must be logged in to reply to this topic.