Raspberry Pi LESSON 45: Using the Raspberry Pi Camera in Bullseye with OpenCV
HTML-код
- Опубликовано: 14 окт 2024
- Announcing the Most Awesome Raspberry Pi Lessons of All Times! This time we RUMBLE!
In this class series, we will be using the most excellent Sunfounder Ultimate Raspberry Pi kit, available here: (Affiliate Link)
amzn.to/3tSk9Mo
or for our UK friends, amzn.to/3I5d401
In this lesson I will show you how to use the Raspberry Pi camera on the Bullseye operating system, in either 32 bit or 64 bit mode. I will show you how to operate the camera using OpenCV.
If you want to grab those cool little straight jumper wires I am using to keep my breadboard builds neat and clean you can snag a box of them here:
amzn.to/36NyfHq
If you guys are interested in the oscilloscope I am using, you can pick one up here (affiliate link):
amzn.to/3v13Mhl
You guys get your hardware ordered so you can follow along at home!
You will also need a Raspberry Pi. I suggest the Raspberry Pi 4. If you do not already have one, this is the most suitable gear I could find:
amzn.to/3pBMfKm
The Raspberry Pi's are sort of pricy right now, so you can look on ebay or elsewhere to see if there are any deals. You will need a SD card. If you do not already have one, this is a good one:
amzn.to/3KcXTn2
I like using a wireless keyboard and mouse to have fewer wires. You can certainly use your USB keyboard and mouse, but if you want a nice wireless one, this one works on the pi. We demonstrate this by using a button switch to control a LED.
amzn.to/36Rv9Sk
You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
/ paulmcwhorter
[Disclosure of Material Connection: I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com. ]
#bullseye
#opencv
#raspberrypi
Hi Proff, you taught me a lot back then when I was a fresher in my early career journey, 7 years ago. Now I'm an Electrical/Electronic Engineer working as an IoT/AI Solutions dev and a tutor. Lot of thanks and I salute you !
Well done! Congratulations on your success.
@@paulmcwhorter forever grateful !
Thanks Paul. What I love about these courses is that it ties together classes I took in the past.
So perpetually envious of the environment that you inhabit. Sometimes I think I watch your vids for the background as much as anything.
Nah, just joshing, the content is great! as always. Stimulation for the imagination!
We really are blessed to live in such a beautiful place. My wife are very deliberate to not become blind to the beautiful spot on the river. We have lunch every day outside on the balcony to enjoy the beautiful view of the river.
Excellent lesson. Python would not work until I had to updated my bullseye firmware to get libcamera library by using: sudo rpi-update.
Also, updated /boot/config.txt file with the following changes:
#start_x=1
camera_auto_detect=1
gpu_mem=256
Found libcamera-hello command was a good way to confirm camera is wired up correctly.
I am still getting " no camera available" when I am testing with libcamera-hello ..any suggestions..?
Thanks! I love the Raspberry Pi Camera videos with OpenCV. Thank you Paul. Also, I just found a SunFounder Video Robot Car Kit for Raspberry Pi 5 /4/3B+/3B.
Python/Blockly (Scratch), Video Courses, Rechargeable Battery (Raspberry Pi NOT Included) Amazon $89.99 This might be one way to learn the RPi5???
Thanks! Really appreciate the support.
OMG,you are my lifesaver,I tried so much ways including pi camera2 face detection program on their official repo but idk it is not working for me,but you are rockingg,Thankyou Somuuchh.If didn't saw this video my last opt was to restart all from 32bit os which will drain my entire work on 64bit.Once Thank you Paul
A lot of thanks you made my University carrer a lot easier, masive thanks proff!!!
Glad to hear that!
Its perfect and the best pick. I tried 10 -15 videos , this gave me the desired output
☺☺☺☺☺
Thanks a lot sir,.
I was trying to connect the camera since last two day, But You code is so simple. I don't know why, But I was not getting any blog regarding the same.
Thanks again
Hi Paul,
Thanks for the series. Ive learned a ton. One small note to others watching the new 5 pi cables from this kit dont fit a raspberry pi 5 slot as it is to small.
These lessons are better suited for earlier version of the Pi. The 5 is really trying to become more of a desktop type machine, and less of an embedded platform. Maybe pickup a used, earlier version of the pi for the class.
Thanks for the response! I have enjoyed the class a lot and learned a ton.
Would a raspberry 3 work for this class or only a 4?
Thanks!
Hi Paul. This is awesome!
It is hard to keep up during the summer, but I'm trying to catch up. Thanks again.
I have followed you loosely on many of your posts. Arduino, Fusion 360, etc. You're an excellent teacher. I find all of your content intriguing and I normally browse your posts as my hobby needs dictate. Thank you for all you do. Unfortunately, I popped into this lesson w/o fully understanding the 64-bit operating repercussions. As a heads up for any of your followers. If they do not install the 64-bit version, i.e. go with default settings on the PI page even though it is a 'fresh install'; they will not be successful in installing the CV-2. At some level I thought the 64-bit vs 32 would just be a performance Hicky...but no...the files structures, etc. are a bit different. Anyway, you earned a Patrion visit from me. Just for the pure tenacity of putting that all together for us. If only I would have popped into lesson 44 1st * smile * . Please keep up the good fight. Rob
It is great to see the Pi camera come to life! Having done the FPS calculation in the AI course, it was a pretty quick addition to the Pi lesson. I am seeing around 18 FPS. It looks good, but is not the 30 FPS that Paul expected. Thanks for the great lesson Paul!
Thanks Paul. I like this video training course. It's useful.
Glad you like it
That was a lot of fun, thanks for your effort and great video production.
Things get fun now we can use the camera.
excellent Video - got the camera working in minutes
Thanks for this interesting new way of using the Pi camera. 😀
Hello Paul. Firstly thank you for putting on these great tutorials. I am having a problem with lesson 45, Getting some errors when installing opencv. Is there somewhere I can go to get assistance? Thank you in advance. Vic
This is exciting stuff. Looking forward to seeing where you take us from here.
Hello Paul. I enjoy your tutorial in this series very much here in Solingen in Germany. Thanks al lot for that. As I'm using Visual Studio Code on my PC, I was very pleased to see that in bullseye this is shown as a Recommended Software. So I installed it and it works very fine with all that very helpfull stuff in programming. It makes coding much easier than in Geany or Thony, which of course I tried as well. Perhaps it's usefull for your community to know that and try that tool. Best regards Bernd
Thanks Bernd und grüße aus Wuppertal!
Grüße aus Mettmann… 😃
thank you for this valuable lesson
Paul just completed 1 thru 44 no issues went great. THANKS Now lesson 45 I installed cv2 as shown in lesson 45
Says sucessfully installed . If type python it says not found. If I type python3 details are show. When I type import cv2 i get the same error as the other student import error can not open shared drives .
Please advised im lost. 1 to 44 went great
Found the issue. Had not installed 64 bit yet. Folded like a cheap WM lawn chair
Great lesson today! Will be working on updating my bullseye and doing homework and getting pico w loaded with micropython. I am up for live stream tomorrow night!!
Sounds great!
nice ideo i love it , can we put this video in format mjpeg and how ? and one more question can we stream that video and how , thanks
I now have three CSI cameras. I tested each of them and the results are listed below. I did notice some lag, but I was using VNC viewer. I dont have a spare screen to verify if that is the cause of the lag. I set the start time prior to the capture statement and the end time after the show statement. I then increment the frame count and add the calculated frame time to the total time. After quit, I divide the frame count by the total time to get the FPS.
Arducam Camera OV5647
5MP 1080P day/night
FPS Res
31.04 1920X1080
44.44 1280X720
24.01 480x360
Sunfounder Camera
FPS Res
30.238 1920X1080
48.939 1280X720
19.371 480x360
Raspberry Pi Camera V2
FPS Res
35.809 1920X1080
65.226 1280X720
40.724 480x360
Think I got the home work. I also tried different resolutions. When I went to 640x360 seems to slow my fps but not as much as 1920x1080. Thanks for this lesson.
Nice work!
Hi Paul, Another high value session. I will be trying to add camera to my current Pico W project and expect this knowledge will be transferrable to Pico. Best regards, Ed
I think you cant use pico with raspberry pi camera modules…
thank you very much Mr. Paul you're awesome :)
Paul, you are awesome!
Hi Paul, first of all thank you for your time and very useful tutorials. Could you put somewhere source code of program you created on tutorials?
No, my objective is to teach people to code, and do not want to tempt people to just copy and paste my code.
@@paulmcwhorter Once again thank you for your time.
Lesson 45 new 64bit Pi added downloads as instructed . Python echoed 3.9.2 cv2 echoed 4.6.0 vcgencmd getcamera returns zeros
Run program I get :
Traceback (most recent call last):
File "", line 3, in
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 254, in __init__
raise RuntimeError("Camera __init__ sequence did not complete.")
RuntimeError: Camera __init__ sequence did not complete.
I even copy paste you program Same thing. Paul love you videos and you are a great teacher.
Also configuration on the new 64 bit Bullseye does not show option to select camera , Should it ?
Just need someone outthere to point me in the right direction .
Hi nice video. Do you have a like to the pir sensor you mention?
you're just amazing ! Thank you very much ❤️
on the fps script, I had to remove the line picam2.preview_configuration.controls.FrameRate=30 to obtain the video with FPS. I am using the USB camera from your previous AI series on the pi400 and obtain FPS of about 20.
I cannot seem to catch up. I am on 14. Can start here or is there stuff I really need to know before I start this lesson
This is sort of a late place to start. I would try to do the earlier lessons.
I was confused why the output was lagging on my machine, I recorded it to an AVI file and playback quality was excellent. I assume the lagging I saw while running the code real time was from the VNC viewer WiFi connection.
Hi Paul, the recommended Raspberry Pi kit is not available currently on Amazon. Any other kit you might recommend for compatibility with your tutorials.
Ok i got it working 😁👍i don't know what it was i couldn't find it . But it works ❤
Hey Paul, I have completed your Arduino series and am now looking to get into this series. I just have one question, can I complete this series with the pi 4 model b or does it have to be the pi 4 model a. Thanks.
Either should work.
@@paulmcwhorter thankyou Paul🙏
Hello Paul, Thank you very much for the video. I have a doubt regarding the camera module. So, I am trying to use ROS on Raspberry pi to build a RC Car due to which I had to install Ubuntu on my Raspberry pi. However, the camera that I have (Freenove 8MP) does get detected by Raspberry pi but does not capture any frames. Can you please assist what I should do in this case?
Hi,
Many thanks for one more excellent tutorial.
I have followed the instructions using the Raspberry Pi HQ camera.
It all works smoothly, however, it looks like the Red and the Blue channels are interchanged.
Blue things look Red, Red things look Blue, and Green things look Green (as well as white).
Looks like an RGB BGR issue.
Do you have any idea what's wrong?
Thanks.
Nahum Budin.
To prove the interchanging, the following fixes the display: frame[:, :, [2,0] = frame[:, :, [0,2]]. Nahum.
i do not have a pi camera, I am using a USB webcam instead, what shoud i change in my code to get the same results.
Can i use this in a virtual enviornment?
So far so good, but what if you use OpenCV to open the camera and grab a frame. Did you find a solution, why it's not possible to use cv2.VideoCapture(-1, cv2.CAP_V4L2)
Hi, face the same problem, did you solved it?
Hi sir, I'm doing a project, for now, can you help me? How can I enable two web cameras at the same time?
I fired up a new my newly delivered RPi 4B today. I tried to install opencv as I did last on my older 4B running Bullseye and it didn't work. A newer version of opencv is available. I installed opencv without specifying the version number and I didn't get any errors installing it. pip install opencv-python
The possible issue will come in that we will be on different versions of opencv, and will my future demos work on your version. I would really try and see if you can get my version installed, that would be safest.
Hey, i am working in a virtual environment. I successfully installed cv2 library in it, but I am unable to install Picamera2 library. Can you help. Thanks
A shift to Python from Debian Linux enabling expanding market for Pi Camera for the several knock-off SBC on the market today. RaspberryPiOrg, et al, showing lack of loyalty by not including the breadth of required code to operate PiCam with Bullseye before its release.🤬
Backward compatibility is a fable.
looking anxiously for saving video to file??
After starting with a fresh install of Bullseye 64 and installing opencv-python, import cv2 complains about a host of missing dependencies. A few minutes with google shows this to be a common problem but I never found the correct solution. Any help greatly appreciated.
Well that was interesting. Upon making a fresh SD with Bullseye I noticed that there are 2 desktop images, one with security updates and desktop environment and another with recommended applications. On my previous attempt I'd used the first option, now I tried the second option. Bingo!! Everything works just fine. I suppose it stands to reason that importing applications also drags in a lot more python libraries.
it's working but the footage I am getting looks zoomed. any solutions?
Greetings from Nigeria, did you use Python programming language for the pi camera
yes
I wonder, will this also work with raspi 5 and camera v3?
The lessons will work with a pi 4. Lots of things changed on the pi 5
Hi Paul, I wonder if you have a Discord server to get in touch with followers of the channel. They work great to share and ask for help on common topics of interest.
No, just too much to try and moderate and monitor a discord server. Maybe at some point.
Does picamera2 have the possibility to access two different cameras in one script? Would be nice to know!
I think it is possible but would run slow with two cameras
@@paulmcwhorter Thanks for the Response. What would you recommend for using 2 cameras?
Hello all. All went well with no errors until i type "import cv2" i get " ImportError: libcblas.so.3: cannot open shared object file: no such file or directory" any suggestions
same thing happend for me
try to update your numpy
Hello I tried this but I can’t get a good frame rate even if I lowered my resolution. I get around 20fps when I reduce the resolution to 360x360. Please help me fix this guys. Thanks in advance.
Homework posted ruclips.net/video/c6Jr0tHpXKc/видео.html
I also show my design of a holder for the Pi Cam and included the Fusion 360 file in the description. I also added a little show and tell of what I have been up to over the holidays.
LEGEND!
Another great learning exercise, Paul! Here is the link to my homework: ruclips.net/video/iEcdQCwPulo/видео.html
I cannot figure out why I am only measuring about 15 fps. I took out the print statement that I was using for troubleshooting, but surprisingly, that doesn't do anything to the fps.
LEGEND!
Here is link to my homework for this lesson, ruclips.net/video/5r9Raz-hIlM/видео.html. There was a considerable amount of head scratching to get it done. Thanks Paul for doing these videos.
James, nice work, but I think you are not getting an accurate number. There are lots of lines of code not between your two measurements of time. You need as much of the loop code as possible between these two lines of code, as each line takes some time to execute, and hence code not between your two time measureuments are not being accounted for. Nice work, think on it a little more.
Here is an update to my homework for lesson 45, ruclips.net/video/FMmEJTisfFA/видео.html
LEGEND!
Homework ruclips.net/user/shortsH0ovfTPWvVM?si=eC-46tTcvTullI43
FPS is based on lighting
LEGEND!
if you ever need an idea on lessons, im trying to learn something called ROS to run on a raspberry pi
I have tried ROS several times and found it very frustrating.