Raspberry Pi 4: OpenCV with Legacy V4L2 Camera Stack on Raspbian 11 (bullseye)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back to another video in this video i wanted to share with you a workaround i found to um get my application the time exposure application that i've been sharing in these recent videos um have it running on raspbian 11 bullseye when i first tried to run the application it used to run fine with the camera the raspberry pi uh camera module version 2 on raspbian 10 buster but in the raspbian 11 bullseye uh a new camera system has been been been used so there was a some issue i my program would not be able to find the camera because it did not find the camera under the same names as before so i wanted to just share that with you and also share a workaround that i found on one of the raspberry pi forums for enabling the legacy camera system so here is the information about the raspberry pi this is a raspberry pi 4 model b it's running um 32-bit version of raspbian 11 bullseye on linux kernel 5 1063 this is uh currently running with the with the new cam lib camera camera system when i try to run my program cv timex it looks for the names of the cameras under slash dev slash video 0. so that device exists but i'm unable to open it with opencv because uh the opencv uh cannot hasn't been i guess upgraded to work with this i'm not sure what the issue is but i'm using in cv timex application i'm using uh opencv and as far as i can see the um cameras devices are there but um opencv is not able to open the camera and also the name of the camera is unicam image this used to be called i believe camera zero in uh buster so the name has changed and this is because this is uh working with the lib camera uh system so if i were to try to use lib cameras utilities um it has a few utilities but let's say lip camera dash hello and if i don't give it any parameters it'll take uh it'll it's going to be able to open the camera and as you can see the camera is capturing the image of the raspberry pi lip camera hello will stop after a short time so if i give it a dash t0 uh lip camera will open the camera and it'll it'll sit there and it'll it's now re basically the camera is pointed at the raspberry pi 4. it's taking a picture of itself and i think you might have seen the the green led blink in in there but anyway so the camera is working with raspbian 11 buster using the lip camera utility utilities but um because my application was written for opencv and the opencv was using the old camera system my application is as a result unable to um to open the camera i came across this page on one of the raspberry pi forums and in here as you can see the title is legacy cameras stack under bullseye and what it's talking about is um well some of the commands like raspberry still and raspberry vid are not available so at the beginning it's talking about how to maybe build those user space utilities but there's also a an indication here that this will allow the um the legacy camera stack to be enabled this post is by um the moderator 6x9 who is a raspberry pi engineer and he's typically got response to camera issues as well and so this was something that seemed credible enough for me to try and so what i'm going to do is i'm going to show you how that helps me at least open uh be able to enable the uh legacy camera system on my raspberry pi i'm going to just follow the um the commands i mean the suggestion in that uh forum post it says that to go to the config.txt and if i search for camera i'll come across this line and the first thing to do is to disable this line by commenting it out camera auto detect equals one that's not enough though i got to come to the bottom and add these two lines i got to give the gpu 128 meg of memory and also i gotta start at set as start x equals one so with those three changes basically disabling the camera auto detection right here commenting that line out and adding these two lines if they don't exist or uncommenting them if they're already commented i just save and reboot so now that the raspberry pi has rebooted it again as you you can see here it's running um raspbian 11 bullseye and just checking back at uh boot config.text just to double check this is got the camera auto detectable one is commented out and at the end in the all section so in the section that's uh in the brackets it says all i've added gpu mem equals 128 and start x equals one i've already rebooted with that what i hope is that the i should be able to run my program and open the camera with my program using opencv as you notice here the camera is detected and now the camera is named camera 0 and my program was able to open it using the old system and it's showing the preview and it's live you can see the green led blinking and if i run capture it's able to capture the images and do what it used to do now all this is done is enabled the camera stack that is the camera drivers the that were used but none of the utilities for raspbian uh get enabled by this in order to get those you you may either have to copy them from another system an older raspbian buster system or you may have to rebuild them from source code and that forum post was referring to some methods of some methods so for example the moderator 6x9 uh showed the instructions on how to build the user land uh stuff and then there's someone else i had suggested maybe copying them from another system and there's some discussions about that but i did not try that myself but there's information here that that might help anyone who might need the older utilities to have to how to get them resurrected on the raspbian 11 bullseye if i come here and stop the program you will see that raspberry still is not found and by the way i look for lip camera that by booting the old cameras stack i no longer can use the lib camera utilities because the lip camera utilities only work on the lip camera stack so by disabling the lip camera stack and enabling the legacy camera stack i lose these utilities but for my purposes i'm fine with that for now until i actually move my application to a newer opencv that can support lib camera on the raspberry raspbian 11 buster for now this is a good solution for me i may end up having to build the raspberry still and raspberry vid videos utilities from source but so far i i don't have a need for that so i haven't had it don't have that procedure to share with you but hopefully the the forum post is something that might be useful to others who are interested in doing that so um again i will post the um link to the forum um article where i i was able to find this information and uh i will post it in the video description i hope this information was useful and hope to see you in another video
Info
Channel: Alan Mikhak
Views: 6,308
Rating: undefined out of 5
Keywords: raspberry pi 4, raspbian 11 bullseye, raspbian bullseye, opencv, libcamera, legacy camera stack
Id: CF6T7KVLn2A
Channel Id: undefined
Length: 11min 39sec (699 seconds)
Published: Tue Nov 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.