We have a raspberry pi camera, the ones with a flexy cable. When connecting it to our rpi with an older sd card that has an older version of wpilibpi (not sure which one, around 2022-early 23) the camera works great, and we can read from it, at very high speeds too. When swapping out that sd for a new install of the latest wpilibpi tho, the frame cannot be read. This isnt a code problem as even with a barebones test that does only that, the “ret” returns false and “Frame” is None. Both are run on the same pi, and Cap.isOpened returns true. The problem is specific to this type of camera, as when connecting a usb camera it works with no issues. If anyone has any insight on how to solve this, or a different approach to the problem, both would be welcome. Currently have tried using the picamera2 library but the fps is about half what it was with opencv on the other card (30-40 instead of 60-70). Might be helpful to note that both sd cards have very similar specs, the one with the new wpilibpi is even slightly better.
if you guys are new to vision for FRC and doesn’t want to go the limelight route, then I would highly suggested that you guys started with the PhotonVision. You can search on that here for a whole bunch of discussions on here or search on that on Github or via the WPILIB. PV is CV base but make things a lot easier for new teams to get into vision.
Choice of coprocessor will have performance restrictions. Choice of cameras will have compatibility issues (to your coprocessor as well as to the PV program).
No, we are not new to cv, and using the pi is a calculated desicion.
I’ve looked quite a lot on here (and obviously other places) and decided to post, but maybe there isnt a good way to solve this problem. Seems a bit wierd tho, it is a native rpi camera and am suprised that its not as widely used, and therefore documented.
Thanks for the advice, though.
then in that case, it sounds more like a driver issue or perhaps compatibility issue with the latest version.
have you guys tried going the photonvision route - Selecting Hardware - PhotonVision Docs
there are some more links to PI specific drivers stuff on there too.
The key issue is that the Pi really broke picam support in newer OS versions, as the picam is no longer autodetected for V4L2 (and you have to do things like use the specific resolution the camera supports). To get things to even work at all, you have to edit /boot/config.txt. See this thread for discussion from last year: Does the WPILibPi image support the Pi Global Shutter Camera
To to follow up with what @Peter_Johnson said, to get the Pi OS environment to even know about the camera, the right settings are needed in the Pi file config.txt stored in /boot (so /boot/config.txt). Earlier this evening, I uploaded the config.txt from a Pi that we have working with a camera using WPILibPi version 2023.2.1 (the latest).
config.txt (2.7 KB)
The main thing to change/verify is the correct image sensor for the camera you want to use is selected. See this block in config.txt:
#dtoverlay=imx219,media-controller=0
#dtoverlay=imx290,clock-frequency=74250000,media-controller=0
#dtoverlay=imx290,clock-frequency=37125000,media-controller=0
#dtoverlay=imx378,media-controller=0
#dtoverlay=ov5647,media-controller=0
#dtoverlay=ov9281,media-controller=0
dtoverlay=imx296
Uncomment / add the image sensor for the camera you want to use.
As for reading images, you will need to go with picamera2, as you noted. Please see a bare-bones image capture loop example that works on WPILibPi version 2023.2.1. This example is here Does the WPILibPi image support the Pi Global Shutter Camera - #12 by sgtrupia.
team100 vision works fine with the newest WPILibPi from Peter’s fork, a v3 rpi camera, and rpi 4b’s, sending structs to NT.
Thanks for the config file, i did manage to find that block earlier tho. The wierd thing is that the camera we are using (picam 1.3) was still commented but was working just not very fast. For some reason there is an fps cap by default, although it didnt look like it as the fps was jumping around from 30-40 and even 40+ at times, but by raising the fps cap the fps went back to how it was originally.
The line that fixed the fps is below:
picam2.set_controls({“FrameRate”: 90})
cool, glad it worked out. I’m curious what resolution you’re using for the high frame rate you want. my understanding of the camera hardware is that really high frame rates are only available using highly cropped modes like 640x480, with a very narrow FOV. is that what you use?
We are actually using 320×240, as this camera used for closer range detection, and therefore is significnalty better while at a low resolution as the fps rises quit a lot.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.