Тёмный

OpenCv and Camera Calibration on a Raspberry Pi 3 

Tiziano Fiorenzani
Подписаться 27 тыс.
Просмотров 89 тыс.
50% 1

We download OpenCV source code and build it on our Raspberry Pi 3. It will take approximately 2 hours!
After the installation we calibrate our Raspberry Pi camera using a chess board and following the procedure stated on the official OpenCV documentation.
*** SHOP NOW at my store and help sustaining the channel:
teespring.com/...
Get the best and sign up to the course ZERO to DRONE PROGRAMMER here: • Become a DRONE PROGRAM...
On my Github you can find a opencv folder, where I put:
- a Readme, for the camera calibration process
- a step by step procedure for the installation
- save_snapshots.py for conveniently save the stills with the Pi Camera
- cameracalib.py, for calibrating the camera (derived from the official one)
My Github: github.com/tiz...
OpenCV Official: opencv.org/
OpenCV Camera Calibration: docs.opencv.or...
Donkey Autonomous Car: www.donkeycar.com/
sentdex OpenCV tutorial series: • Intro and loading Imag...
**** How to get started ******
• Get a new Raspberry Pi here: amzn.to/2vBmAFQ
• Get a Raspberry Pi camera: amzn.to/2OVj7Kp
• Get a complete Diy kit for your Raspberry Pi projects: amzn.to/2KLhn38
** Go to my channel: goo.gl/BjLGnS
** Check out my latest video: goo.gl/ZhcNi4
** Check out my most popular video: goo.gl/5KMJnU
*** JOIN THE FACEBOOK COMMUNITY: / tizianotutorials

Опубликовано:

 

15 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 140   
@limonparanoico
@limonparanoico 6 лет назад
Thanks! this is the one and only tutorial that works for me, great explanation, thank you so much. Before this, installing OpenCV was a headache, can't wait to see your next videos =)
@sardorbekkhujaev7706
@sardorbekkhujaev7706 3 года назад
I am very grateful to you for making it so clear and easy!
@prandtlmayer
@prandtlmayer 3 года назад
You're very welcome!
@kazimafzal
@kazimafzal 6 лет назад
Love the projects you're doing!! Looking forward to seeing more videos like this!
@screenapple1660
@screenapple1660 5 лет назад
OpenCV is like Children with Autism. When you program it. The autism child will learn to stay focus. Finally, I discovered the answers. Was thinking about using OpenCV to focus Autism eye movement.
@hlkihglkhglkhg
@hlkihglkhglkhg 6 лет назад
love your stuff mate. Thanks heaps
@ashishaggarwal947
@ashishaggarwal947 6 лет назад
thank you for making this video ...
@백승원-c8t
@백승원-c8t 6 лет назад
thank you my bro. i love you
@filiperibeiro4768
@filiperibeiro4768 4 года назад
Great tutorial, god bless u
@onkarkoli458
@onkarkoli458 5 лет назад
Excellent and easy
@prandtlmayer
@prandtlmayer 5 лет назад
In my new series about ROS we are going to cover the same setup. Just... In a while
@jianhuaixie
@jianhuaixie 6 лет назад
woo,the video is coming.
@tonyjames1980
@tonyjames1980 5 лет назад
Thanks Sir, Nice tutorial
@agcreatortn
@agcreatortn 6 лет назад
Followed along with video at min mark 4:31 you say to check interpreter. Mine shows as python 3.4. Not sure why, libraries under interpreter are libpyhton3.4m.s. how do i fix this?
@prandtlmayer
@prandtlmayer 6 лет назад
Have you completed the installation? Does python find the cv2 package?
@jianhuaixie
@jianhuaixie 6 лет назад
the next video is so intersting.
@prandtlmayer
@prandtlmayer 6 лет назад
Thanks, nothing special, but I would have loved had I found something similar when I started
@jianhuaixie
@jianhuaixie 6 лет назад
yes,do you known some jobs about ros and RL(reinforcement learning) in USA? I will appreciate that If you could interpolate.
@stentechy3346
@stentechy3346 4 месяца назад
Nice video. How do I get the real life x y z cordinates?
@JARC99_
@JARC99_ 4 года назад
Hello! I first want to thank you for this awesome viedo and channel, it has served as a great inspiration for a bunch of academic and personal projects I am planning on undertaking. Using OpenCV for object detection and tracking on UAV platforms is one of the topics I am interested in and I'm looking into buying a Raspberry Pi 4 for this. I am kinda of on a budget so I wanted to ask you Sir, whether the 2GB Raspberry Pi 4 would be enoguh for this application or if getting more RAM would be mandatory? Best regards :-)
@prandtlmayer
@prandtlmayer 4 года назад
Hard to say, but I'd go with the 2Gb and eventually put it for sale and upgrade to the 4gb if you see it does not fit
@kerron_
@kerron_ 5 лет назад
good video
@ihluch
@ihluch 5 лет назад
I got the parameters from another source. is there any way of then applying them to the picamera? i am quite a noob when it comes to stuff like this, sos any help is appreciated.
@firozwadud5425
@firozwadud5425 3 года назад
Do I need to calibrate the camera even if I run the program on laptop and use a webcam? if so, how can I calibrate my laptops webcam?
@bousiffares257
@bousiffares257 4 года назад
thank you Pro
@garethtate4104
@garethtate4104 3 года назад
Hello Tiziano. Thanks for the video. I assume if you are capturing at a higher resolution, you need to calibrate for that resolution. How do I enable the snapshots preview window (and calibration windows) to be resized on the rpi display for higher resolutions? I currently can only see some of the image. My X11 forwarding to mac is not working so I am hoping there is a workaround.
@prandtlmayer
@prandtlmayer 3 года назад
You are right, and if you look at my script, you can submit the resolution as argument. In general I would not recommend going higher than 640x480 for real time applications though
@noahorosw
@noahorosw 6 лет назад
I can't wait to follow you in the next video tutorial It's only going to cost 1,100 dollars .
@noahorosw
@noahorosw 6 лет назад
Good thing I bought extra batteries
@prandtlmayer
@prandtlmayer 6 лет назад
LOL, yes, it's a little expensive, but most of the stuff I will develop on this board will apply to other architectures. For example I am going to develop for PX4 as well, the board runs Linux Ubuntu and the intel realsense camera can be installed even on other companion PC's.
@zhaobangxue6306
@zhaobangxue6306 3 года назад
why is the procedure when I do make -j4, the procedure stopped at 40% percent. and there is error showing
@prandtlmayer
@prandtlmayer 3 года назад
Compiling OpenCv is sometimes tricky. Clear the build and try again
@sayalipatil2562
@sayalipatil2562 4 года назад
Hi Tiziano, will you please help me with the error mentioned below?? cd drone/how_do_drones_work/ is not working. It is showing the following error: -bash: cd: drone/how_do_drones_work/: No such file or directory.
@prandtlmayer
@prandtlmayer 4 года назад
That is related to where you are cd-ing from. Type ls and see wether you actually have drone in your current folder
@daBAAAAM
@daBAAAAM 2 года назад
Hello Tiziano! I have a question about the cameracalib-file.. I noticed that you use the dimensions of the checkerboard in the parameter criteria. In the OpenCV documentation I found that this value represents the maximum amount of iterations. Maybe I am interpretating this wrong.. The dimensions are only used in this parameter. Does that mean the dimensions of the single square of the checkerboard is not relevant?
@prandtlmayer
@prandtlmayer 2 года назад
The dimensions of the single check are important as you need to connect the pixels to physical dimensions. The unit of measure you use in calibration will be used to give you the dimensions from there on
@daBAAAAM
@daBAAAAM 2 года назад
@@prandtlmayer I see, but I don't find the line of code where the pixels get the connection to the physical dimension.. There should be some sort of comparison between the size of a single check and the width of it in pixels.
@sandrolosa9530
@sandrolosa9530 6 лет назад
Hey Tiziano, Great Video:-) If I print the chessboard, is the size of the squares important? If yes, what shall the exact size of a square be (9x6 chessboard)? Thanks a lot for your information.
@sandrolosa9530
@sandrolosa9530 6 лет назад
I have found the answer within the code. The squares should be 25 mm each. Thanks a lot for that awesome work:-)
@jojosbizzarestudio560
@jojosbizzarestudio560 2 года назад
Hi Tiziano, First thanks for this amazing video! Really brought me in. Second comes the question, I tried to install libjpeg-dve, libtiff5-dev, lib jasper, lib png12, but some error occured saying 404 not found. Is this because of the resources online's gone? (I'm using college wifi so I also guess my college block some of the website?)
@prandtlmayer
@prandtlmayer 2 года назад
I don't believe your connection is blocking you and it might be that, since the video was released, installation has changed. Try installing OpenCv as a package
@robert.von.l
@robert.von.l 5 лет назад
Hi, I wanted to know if the program only works with special cameras like the one in the video, or pocketcameras like a canon connected by usb also work. Thank you in advance for your help, I am a starter :P
@prandtlmayer
@prandtlmayer 5 лет назад
It works with any camera you can install
@thoipham3134
@thoipham3134 4 года назад
Hi Tiziano, how do you use camera matrix and distortion coefficients for calculate X, Y, Z Real World Coordinates ? Thanks !
@prandtlmayer
@prandtlmayer 4 года назад
Camera intrinsic parameters are very important moving from the distorted view of the lens to the camera frame. That allows you to actually work with projections. From there you can calculate stereo disparity map, VIO...
@nidalfayad3689
@nidalfayad3689 3 года назад
Hello Tiziano.. Thanks for the great video. When I start calibration the camera is running slow I have v2.1 & PI 3B kindly can I do something with configuration? and when I enter space it doesn't save (only one time worked).
@prandtlmayer
@prandtlmayer 3 года назад
I think we have the same setup: I also have a 3B+ here and a normal pi-camera: what resolution?
@shaikha.malzaabi7286
@shaikha.malzaabi7286 2 года назад
Thank you for the video! I was wondering if I have 2 values in the error matrix around 600. is it too high? and how can I reduce it?
@prandtlmayer
@prandtlmayer 2 года назад
An error of 600? Are you sure that is the error and not the calibration matrix?
@Jptoutant
@Jptoutant Год назад
on my pi 3 with a fresh ubuntu server install, just the first 4-5 packages took all day lol. isnt there an imaged distribition somewhere with ROS and openCV just right off the bat? would be cool
@Jptoutant
@Jptoutant Год назад
very happy to start working with your videos. mountains of information
@prandtlmayer
@prandtlmayer Год назад
I am glad you find them useful. The image that I recommend comes with ROS installed already. OpenCv should not take that long to install on Ubuntu
@talhahilal3588
@talhahilal3588 5 лет назад
when i run open CV webcam window shows nothing but black screen however the web cam is working just fine when checked separately on my PC... need help !!
@prandtlmayer
@prandtlmayer 5 лет назад
Maybe you just need to select the proper video source id, rather than video0
@rohitjoshuarajasekar6046
@rohitjoshuarajasekar6046 3 года назад
After camera calibration execution, it says name 'xrange' is not defined. What might be the problem?
@prandtlmayer
@prandtlmayer 3 года назад
might be stackoverflow.com/questions/17192158/nameerror-global-name-xrange-is-not-defined-in-python-3
@isaachenderson1927
@isaachenderson1927 5 лет назад
Hallo, I'm getting the make file error make: *** No targets specified and no makefile found. Stop. when i tried to execute make -j4
@prandtlmayer
@prandtlmayer 5 лет назад
Have you run the make?
@saravaka
@saravaka 6 лет назад
Jump to calibration? 5:10
@callenkoiner2785
@callenkoiner2785 5 лет назад
Anyway you could post the code for save snapshots? Also, how do you use the camera matrix and distortion coefficients to actually undistort other images you take? Thanks!
@prandtlmayer
@prandtlmayer 5 лет назад
Everything is on GitHub. Check it out
@callenkoiner2785
@callenkoiner2785 5 лет назад
@@prandtlmayer Thank you, got a new sub from me! I'm getting the following error when I try to run camercalib.py: Traceback (most recent last call): File "camercalib.py", line 88, in corners2 = cv2.cornersSubPix(gray, corners, (11,11), (-1,-1), criteria) TypeError: integer argument expected, got float Any idea why? Extreme python noob here
@thoipham3134
@thoipham3134 4 года назад
@@prandtlmayer Hi Tiziano, how do you use camera matrix and distortion coefficients for calculate X, Y, Z Real World Coordinates ? Thanks !
@bryankoh3836
@bryankoh3836 5 лет назад
Hi tisizano, im getting this error on the cameracalib.py file after selecting the good and bad images. for i in xrange(len(objpoints)): NameError: name 'xrange' is not defined may i know how to solve this error?
@prandtlmayer
@prandtlmayer 5 лет назад
Call it with python 2, xrange doesn't exist in python 3
@yourstrulysidhu
@yourstrulysidhu 6 лет назад
I ran the command again and faced this problem. VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/pi/opencv-3.4.0/modules/highgui/src/window.cpp, line 331 Traceback (most recent call last): File "savesnapshots.py", line 99, in main() File "savesnapshots.py", line 94, in main save_snaps(width=args.dwidth, height=args.dheight, name=args.name, folder=args.folder, raspi=args.raspi) File "savesnapshots.py", line 55, in save_snaps cv2.imshow('camera', frame) cv2.error: /home/pi/opencv-3.4.0/modules/highgui/src/window.cpp:331: error: (-215) size.width>0 && size.height>0 in function imshow Please help me out!
@prandtlmayer
@prandtlmayer 6 лет назад
.mmmhh, it sounds like an issue with the camera. Type raspivid -t 0 and check whether you see the video
@arpitsrivastava8431
@arpitsrivastava8431 6 лет назад
Camera calibaration is for stereo vision
@prandtlmayer
@prandtlmayer 6 лет назад
You need to calibrate the camera before the stereo. Opencv allows you to do it together if I am not mistaken. The calibration estimates the intrinsic parameters. That might be a good idea to add a video for that.
@noe-subdireccioninnovacion3551
I got an error at 62%, I'm using a raspberry pi 3, it says Makefile:160: recipe for target 'all' failed make: *** [all] Error 2 What can I do to fix this issue?
@prandtlmayer
@prandtlmayer 5 лет назад
Look at other comments. Failing during compiling is not unusual. Make sure you had expanded the virtual memory, make clean and try again
@CorporateCat
@CorporateCat 3 года назад
can we use this with opencv 4.5.1 and opencv_contrib 4.5.1? Because I was getting build errors
@prandtlmayer
@prandtlmayer 3 года назад
OpenCv changes, and you might need to adapt some syntax to the new releases
@saeedjohar1150
@saeedjohar1150 6 лет назад
Hey, While running make -j4 I am getting an error which states as follows [ 34%] Built target opencv_plot [ 34%] Built target opencv_photo [ 34%] Built target opencv_reg Makefile:160: recipe for target 'all' failed make: *** [all] Error 2
@prandtlmayer
@prandtlmayer 6 лет назад
Clean the build that try again. If happens again, try make without -j4. Clean the build though
@saeedjohar1150
@saeedjohar1150 6 лет назад
Tiziano Fiorenzani it worked. Thanks. You saved the day
@steelalexstar
@steelalexstar 4 года назад
Hi ! my camera is super slow and laggy. almost looks like a powerpoint... any help please ?
@prandtlmayer
@prandtlmayer 4 года назад
That depends on the resolution you choose
@pranansyahhidayat4713
@pranansyahhidayat4713 4 года назад
Hey, it such a great video! Thankyou so much! Anyway, when i was trying to make -j4 it’s getting stuck at 85% building CXX object samples/cpp/CMakeFiles/example_tvl1_optical_flow.dir/tvl1_optical_flow.cpp.o and the cursor is delaying and so slow. Is it normal? And what should i do?
@prandtlmayer
@prandtlmayer 4 года назад
It's sort of a pain. Make sure you have expanded the Virtual memory first. Then try again
@pranansyahhidayat4713
@pranansyahhidayat4713 4 года назад
Tiziano Fiorenzani Thankyou so much!
@abhinavreddyk4954
@abhinavreddyk4954 5 лет назад
Hey Tiziano! My compiling is stopping at 98 like from past 4-6 hrs it's 98. I used make clean and tried for 5-6 times, I didn't work. Thank you!
@prandtlmayer
@prandtlmayer 5 лет назад
Did you expand the memory?
@MegaHellx
@MegaHellx 5 лет назад
@@prandtlmayer i have the same issue, i have sd card of 16GB and it shows me after loading Rasbian OS root size as 15gb and 4..5gb used and 9.5 available. still opencv Make -j4 stops at 85%
@rishavbhowmik7778
@rishavbhowmik7778 5 лет назад
Can someone tell me how simply run an open cl code using C++ on raspbian.
@johnmelbolaybolay6725
@johnmelbolaybolay6725 Год назад
Why is it that I can't have good pictures? I always have 0 good pictures
@prandtlmayer
@prandtlmayer Год назад
Weird, what resolution did you set it at?
@Pilua_hanuman
@Pilua_hanuman 5 лет назад
Where I can buy this intel board or you suggest me better or cheaper . Thanks to hearing me
@prandtlmayer
@prandtlmayer 5 лет назад
What do you need to run?
@Pilua_hanuman
@Pilua_hanuman 5 лет назад
@@prandtlmayer i am vision programmer so i am looking for ready drone and execute my c++ /opencv code into it. i have zero knowledge of hardware so i don't want to build up drone. can you please suggest me a drone and where i can buy it.
@prandtlmayer
@prandtlmayer 5 лет назад
A good star could be the SkyViper ardupilot.org/copter/docs/skyrocket.html
@ryanbayona409
@ryanbayona409 4 года назад
Do I need to calibrate my camera everytime I boot up raspberry pi?
@prandtlmayer
@prandtlmayer 4 года назад
No
@nhatlequocnhat7183
@nhatlequocnhat7183 6 лет назад
what is the unit using for focal length? cm, inch or whatelses? thank you
@prandtlmayer
@prandtlmayer 6 лет назад
Nhat, sorry for my answer, I read it wrong. The right answer is that the focal length is in pixels. The units of the calibration matrix is pixel
@fdksdk4843
@fdksdk4843 6 лет назад
How to find the cell dimension?
@diasmondmiles3584
@diasmondmiles3584 6 лет назад
i am getting error in -D BUILD EXAMPLES=ON .. it says parse error in command line argument: -D Should be: VAR:type=value plz help me out
@prandtlmayer
@prandtlmayer 6 лет назад
I never faced that issue: check this out stackoverflow.com/questions/31103551/error-in-cmake-opencv-parse-error-in-command-line-argument-d/31374243
@BMWBoyeeM3
@BMWBoyeeM3 6 лет назад
I am getting the same error.
@BMWBoyeeM3
@BMWBoyeeM3 6 лет назад
It's building now. Must have had something spelled or spaced wrong.
@roderickdiaz3834
@roderickdiaz3834 6 лет назад
how resolved? i have problem try -D BUILD EXAMPLES=ON .. and out error -D BUILD_EXAMPLES=ON .. i have out error and -D BUILD_EXAMPLES= ON .. also errors I do not know what to do ._.
@celinkethziaxavier651
@celinkethziaxavier651 3 года назад
Anyone know about correcting fisheye effect in video streaming
@prandtlmayer
@prandtlmayer 3 года назад
If you calibrate the camera and get the distortion parameters, there are ways to rectify the image
@Aidokinn
@Aidokinn 3 года назад
Fantastic guide thank you. However my installs did not go as planned. I copied all your commands very carefully but perhaps I made a mistake somewhere and it let me continue on without everything. I am missing openCV packages after checking output from this as you instructed: cmake -D CMAKE_BUILD_TYPE=RELEASE \ ... and the following few lines. This was outputted at the bottom of the large run sequence (again all terminal): Configuring incomplete, errors occurred! Then I tried: make -j4 and got this error message: make: *** No targets specified and no makefile found. Stop. Can anyone point me in the right direction?
@charlieli7486
@charlieli7486 6 лет назад
Unfortunately, "saving image 0, 1, 2" doesn't even show on my Raspberry command line..
@charlieli7486
@charlieli7486 6 лет назад
haha just realized i didnt press space
@roderickdiaz3834
@roderickdiaz3834 6 лет назад
what different this python3 and python2 ?? can use python 3 for this tutorial?
@prandtlmayer
@prandtlmayer 6 лет назад
Roderick Diaz sure, be sure my library works with 3 though
@roderickdiaz3834
@roderickdiaz3834 6 лет назад
thanks, I realized that it does not work with python2.7 but when I run python3 import cv2 if it works
@prandtlmayer
@prandtlmayer 6 лет назад
I am glad
@abhinavreddyk4954
@abhinavreddyk4954 5 лет назад
Yah I expanded the memory!
@prandtlmayer
@prandtlmayer 5 лет назад
Ah. Usually when I get that stuck is because I'd forget to increase the swap memory. What happ be if you stop it and you try again without cleaning?
@abhinavreddyk4954
@abhinavreddyk4954 5 лет назад
@@prandtlmayer It keeps showing the same percentage for hours
@omegdev
@omegdev 4 года назад
it isnt working. (Raspberry pi 3b+ )
@prandtlmayer
@prandtlmayer 4 года назад
Probably you missed some step: can you be more specific?
@swapnadiphaldar885
@swapnadiphaldar885 6 лет назад
please help me
@AntonioLemos66
@AntonioLemos66 4 года назад
👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼🖖🏼😎👍
@xiaohanzhou2262
@xiaohanzhou2262 5 лет назад
感谢分享
Далее
Forget About Raspberry Pi! Use Your Old Phone Instead.
9:09
ЗАБЛУДИЛИСЬ В ТРАВЕ #shorts
00:25
Просмотров 370 тыс.
Control ANY COMPUTER with these Pi KVMs!
17:46
Просмотров 825 тыс.
Raspberry Pi Object Detection Tutorial
9:20
Просмотров 79 тыс.
Auto-Measuring with OpenCV + Python - Try It Yourself
25:17
I've never seen ANYTHING like this before... Temple OS
17:57
Raspberry Pi Camera Group Test
18:52
Просмотров 130 тыс.
The coolest robot I've ever built!
19:40
Просмотров 4,6 млн
ЗАБЛУДИЛИСЬ В ТРАВЕ #shorts
00:25
Просмотров 370 тыс.