-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
camera reports "select timeout" in RP 3b+ - uvcvideo settings problematic? #44
Comments
Dear purethermal team and community, it seems like this issue cam be tracked down to the quirks parameter https://www.ideasonboard.org/uvc/faq/ of the Linux kernel. More or less by experimenting around, I found out that quirks = 0x400 seems to be a well fitting parameter to combine two pure thermal boards with a pi 3b+. However this setting does not work, when using the cameras at my laptop (x86, Ubuntu 18.04). Starting and running two cameras without - at least so far - seg faults was able going for quirks = 0x200. WARNING: removing and changing the uvc settings in your kernel might crash other stuff running on your system. Please make sure you store your momentary settings first to potentially come back to a working state later on. First get the current value (you might also have a look into the other parameters (no drop, timeout, ..): Then remove the uvc video parameters: Next insert the new parameters. Note: quirks = 0x400 worked for me but might be adjusted for your setup and kernel: Since I give both camera a divice id specific /dev/video*-address, I need to reload the rules and the v4l module in the following, by: Please comment if you encounter any problems or have some more background information on this issue! BR |
Just to get a bit more info, is the RPI3 using Ethernet too? You need to think that before RPI4, Ethernet and USB buses are shared, so a "big" ethernet traffic can cause problems in the USB bus. And PT boards ask for a bigger bandwith than they really need if you only need the radiometric info with Y16 format. Also, even though it does not seem your problem, if the camera is not perfectly attached to the PT board, it can cause "select timeout" randomly. And when one happens, it stays like that until the camera is restarted. I usually solve the select timeout problem firmly attaching the camera to the PT board, reducing the bandwith needed to minimum to run Y16 format (modifying source firmware and burning it to PT board) and I also moved to RPI4, that has the USB bus NOT shared with Ethernet. I've been able to run a USB RGB camera + PT Mini board for more than a month without issues. |
Dear Albert, first of all thanks a lot for your reply! Your solution sounds highly interesting and realls helpful to me, since I'm starting to run into bandwidth errors. The pi streams the two cameras images to a workstation, where they are visualized. I sometimes use a picam v2 at low framerate and resolution, which just kills the stream within seconds so bandwidth is an issue, yes. First of all: Second: I look forward to hear from you! BR |
Hi, Sorry for the late reply. I don't know why I did not get the notification! So, the modifications needed to be done to the firmware are listed here: groupgets/purethermal1-firmware#24 (comment) Supposedly, this is already integrated in the new release, but I always apply this patch to reduce the bandwith of the PT to the minimum (I'm also using 2 RGB cameras with 1 raspberry pi, so I want to avoid USB bandwith issues). I simply modify all packets size that I find in the firmware to 482, because I only use the camera as Y16 to obtain temperatures so that's the minimum for them to work. After doing the modification, compile and flash the firmware. |
Dear @agjunyent, I still didn't manage to fix this issue. Could you maybe help me with a more detailled information on how to change the firmware and what exactly needs to be changed? Or could you send me the adjusted firmware version that you are using? I'm new to firmware issues and don't really know in which of those 100 files I need to look and how to compile my changes properly. BR from Germany |
HI again @sebasgra39! Let's try to work on this. So, let's start: how are you reading the images? Could you provide a very simple script that you use to read them? |
Hi @agjunyent, wow, thanks a lot for the fast reply! I use two of the cameras as a stereo system. All my code is supposed to run in ros using video_stream_opencv. The script that I use two run both cameras is attached below. To match the upload-rules, i copied the code into a text document. |
I also dived a little deeper into the firmware 1.3.0 to understand your solution here:
The // USB Video device class specification version 1.10 code says:
Which is already different to Kurt Kiefers solution that you referred to later on. Where do I select the Alternative packet size? And additionally, what video format could you recommend and where do I set the format of my choice? BR |
Ok, so you are using the ros package to retrieve images. I'd suggest you two things: 1.- Create a simple python script to read from both cameras at the same time for a while. Here is what I use. Take a look that I have some configuration that the ros nodelet does not have, say the fourcc, the rgb=false, and width and height. I've found all these steps necessary for OpenCV to select the correct video format for both radiometry and low bandwith
Leave this running for some time, starting it twice, once for each camera editing the 2.- After 1 has run for some time without problems, try to download the ros nodelet and compile it yourself, modifying the code adding the configuration parameters of python, say
BEFORE starting to grab images with cap->read() Let's see if the python script is able to run for some time this way. I've had it running for over a month, no issues |
Yes, I am usig ROS. To be honest, I can't really follow your instructions. I'm not a software engineer originally and not familiar with python yet. Coming to the second part of your answer, what nodelet do you mean exactly? This one: https://github.com/ros-drivers/video_stream_opencv/blob/master/src/video_stream.cpp ? Regarding the modification of the firmware, I was able to change the format from YUV to Y16, but timeouts occured at one of the two cameras again after some minutes. Changing the packet size to 482 reproduced the error under Kurts Bug fix from 2019, so 642 might really be the lowest option. I really don't get this problem, since both cameras worked fine for days, when they were attached to my Laptop, but are randomly buggy when being attached to the pi. What do you think is the error? |
Regarding your last question, the problem could be that the Pi only has 1 USB bus that manages all USB ports, while usually computers have more than 1 USB bus. The cameras are sending too much data for the bus to manage, and at the end one timeouts because the bus is "full". Let's go step by step. Even without knowledge of python, try to copy this into a python script, and run it with python3:
This script will initialize both cameras with devices 6 and 7 (as in your launch file), set all parameters and start reading from them. Every minute more or less you should see on screen the number of frames each of them have read up until that moment. Leave it running for some time and see if it gets stuck, stops working or an error appears (I was getting an error that read 'select timeout' before configuring the way I'm doing it here) If you don't have python3 you can install it and OpenCV with |
Hey Albert, thanks for your stunning support! When running the python script containing the code above, I receive this:
Is this error familiar to you? BR |
Hey @agjunyent man, the cameras ran smoothly yesterday for the first time! Adjusting the (myterious) quirks-parameter was still necessary, yet succeessful this time. Big thanks! Instead of my previous ROS-code, I also switched to the solution provided here: : https://automaticaddison.com/working-with-ros-and-opencv-in-ros-noetic/ There is only one thing that needs further testing now. Changing the Image Pixel Format to Y16 (what I'll need in my case) as you suggested in your code: cap_left.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('Y', '1', '6', ' ')) Returns all-black images with only a cryptic last image row. Is a modification of the firmware necessary in prior (at the moment, the boards run fw.1.3.0). All the best from Aachen |
Hi, sorry for my very late reply. Don't know if you still here... Been on vacations. Do you have experience in linux services? Maybe you are missing to 'configure' the camera and the driver to accept additional parameters. The idea is to create a service that triggers on boot or on plug of the camera to configure the parameters. I'll post it on Monday |
Hi @agjunyent , BR |
Hi @sebasgra39 Let me try to explain how do I do this.
Create a file in What this does it create a symlink to /dev/lepton_camera when it detects a lepton connected. This is based on Purethermal Mini 2, so if you have a different board, change ATTRS{idVendor} and ATTRS{idProduct} to the ones of yours, listed in lsbusb:
This loads the parameters of the camera to be accessed later, that we do in the last line with lep_cid_vid_lut_select=6, selecting the video type 6 which is "grayscale with temperature values"
Activate and enable the service with REBOOT.
In the variable That's all I do, I think. Give it a try and post here if you have any error, problem or question. Agjunyent |
Hi @agjunyent Thank you for your suggestions. When I print out I use pureThermal2 with Flir 3.5 which is connected to Pi via USB. Best regards, |
@ArtuursK my bad! This has been long time with a bug!! Line 10 should be
Ret and img are wrong! |
Hi @agjunyent, Thanks for your quick reply. Unfortunately I was not able to fix my issue after your suggestion. I have now decided to switch to and test some other SBCs like Khadas vim1s which can run ubuntu server. Best regards, |
Sorry to hear that. |
Dear groupgets,
for a longer period of time, we don't get the module to work constantly over a longer period of time. Might there be a thermal or buffer issue with your module?
Our setup:
We have several modules and cameras which report the exact same issues.
Is there anything you can suggest trying or any specific uvcvideo settings to try out?
I'm looking forward on your reply!
The text was updated successfully, but these errors were encountered: