How to Install OpenCV on your Raspberry Pi!! | Step by Step Tutorial | Using Cmake

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to hope you guys are doing well and staying safe and today in this video what we're going to show you is how to install the opencv library onto your raspberry pi using cmake so stay tuned so if you don't know what opencv is it's basically a library that is used for image detection and image processing so basically you can use this library mainly to make projects like face detection number plate detection that you see on highway tools to just identify number plates of cars and vehicles basically installing this library is a little comprehensive and a complex process so we will be showing you step by step on how to install this using cmake so make sure that you watch this video to its entirety till the end to understand how to install opencv onto your raspberry pi over here in this video i am using raspberry pi onto my laptop as a headless display i'll be connecting my raspberry pi to putty and vnc that is on my laptop and i'll be operating this on through my laptop if you don't know how to make this setup and how to use your raspberry pi through your laptop we have made an entire video showing how to use your raspberry pi to a headless display you can watch it right here so let me jump straight onto my raspberry pi over here on my laptop and show you step by step on how to install opencv library basically what you have to do is go to a terminal on your raspberry pi and just type in sudo raspi dash config and it'll open the configuration folder just go to advanced options and expand file system just press that and it will ask you to reboot basically why we're doing this is that it expands the file system and there is no shortage of space on the system that we are working just press enter over here and because it will ask to reboot on the next step and all you have to do is just press on finish just one second finish and it will reboot now press yes raspberry pi is now rebooting and the next step that we have to do after rebooting is this the next thing that we have to do is just update and upgrade our system the way you have to do is just write these codes into your terminal and that is sudo app dash get update and and sudo apt dash get update and just press enter and once you press enter the entire process will be upgraded and updated your whole raspberry pi will be updated to the latest version this whole process will take about 10 to 15 minutes of your time and that will be it your raspberry pi will be updated to the latest version this entire process of installing the opencv onto your raspberry pi both libraries and everything will take about an hour ish of your time if you're working with the raspberry pi 4 4v or 400 but if you're working with something like a raspberry pi 3 or a 3b like older models it will take more time because the processing power of the four and four b's are much higher and much better than the ones in the raspberry pi 3s and once this is updated the only thing that you have to do is just update it again and that is by sudo dash get update and it's done it'll hardly take a minute and uh yeah your raspberry pi is updated to the latest version so the next thing that we have to do is install something called snap d now the snap d is used to install cmake onto our raspberry pi now all these things all the steps that we take into this entire tutorial are interconnected and every step is really important so make sure that you're watching this entirely and just following these steps all the steps and not miss any one of them because if you miss any of the steps the entire opencv is not basically going to install onto your raspberry pi and yeah it's just going to take a lot of time and it's just going to be a lot of time wasted because you just missed one step all these steps are important so make sure that you follow all these steps properly it is a comprehensive process but at the end the project that you make will be fun and they'll be great and it'll work perfectly the way you install snapd onto your raspberry pi is just by typing this code into your terminal and that is sudo apt install snapd it will be updated and installed in no time the next thing that you have to do is install cmake using snapd and the way you do it is by entering this code that is sudo snap install cma classic now sometimes after you just type in this code and press enter it might give an error and it might not install cma the way you can fix that error is by doing this you have to go to your raspberry pi configuration and just change your gpu memory to a certain amount i'll show you that and go to preferences raspberry pi configuration and then once it opens go to performance and then just make sure that your gpu memory is 256 and nothing less than that because once it's 256 there will be no errors and cmake will install with no errors so once you're done with that just type in that code again sudo snap install cmake dash classic just press enter and cmake will install onto your raspberry pi without any errors the next thing that you have to do after installing cmake is install python 3 onto your raspberry pi if you already have it just make sure that you just install this and the way you do it is just by typing sudo app dash get installed python 3 dash dev and press enter and install in mind this is in my system the python 3 was already installed so that's why it's just showing that all the new latest version is already installed in yours it might just take like a second or so to install and python 3 will be on your raspberry pi and it'll go perfectly after installing python what we're going to be downloading basically from the terminal is opencv 4.0 4.0.0 version we are not downloading and using the latest version as we don't know if they're prone to errors and just everything like that it's how stable it is we just don't have no idea opencv 4.0.0 is stable and works perfectly we have tested it so that is the version that we are going to be downloading and showing you how to the way you're going to be downloading opencv 4.0.0 onto your raspberry pi is by just typing this command onto your terminal and that command is basically wget zero opencv dot zip https github.com slash opencv slash opencv archive slash 4.0 press enter and opencv will be downloaded the whole zip file will be downloaded onto your raspberry pi now after downloading the opencv zip file we have to download the opencv cartrip zip file it has an extended library and this is really important for your entire opencv to work so make sure that you're downloading that too the way you with a download little change and that is wget 0 opencv underscore contrib.zip just https github dot com slash opencv slash opencv slash archive archive slash 4.0.0.zip and just press enter and your opencv contrib file will be downloaded.zip file of your opencv controller will be downloaded onto your raspberry pi after downloading all these zip files what you have to do is unzip them and the way you do that is just by typing unzip space opencv.zip and it will unzip your opencv folder and you have to unzip your contact folder too so the way you do that is unzip opencv underscore contrib.zip and that will unzip too and both your opencv and opencv cartridge folders are now unzipped and ready to use move on to the next step the next thing that we are going to be installing is numpy now numpy is a library for python that adds support for multi-dimensional arrays matrices everything of that sort so we're going to be installing that and that's going to be really necessary for all your opencv projects your image detection processing everything so numpy is going to be installed and the way you install numpy is by typing pip install numpy and just press enter and numpy will be installed in a matter of seconds and that is it numpy is now installed onto your raspberry pi after installing numpy this is a really important step what we're going to be doing is making the build folder inside our opencv zip folder that we unzip now we're going to making the build folder and we're going to start commanding and writing commands into that build folder all the libraries and everything will be installed inside that build folder the way you do that is by typing these lines of codes and what they'll do is just make the build folder and then you start commanding and inside the build folder so we do that is just by typing cd slash opencv 4.0 and press enter then just type mkdir build this is making the build folder and then just write cd build which is we are now writing all the commands into the build folder and after you've just typed cd build make sure that you copy these lines of code into your command prompt that is terminal what these lines of codes are going to do is just install and command your opencv to do these things and just install all these libraries inside the facebook it's really important by the way we have written an entire blog just explaining all these processes and all the code everything step by step is given in that blog it's the first link down description check it out copy and paste this line of code inside that if you want all the codes are there you can just copy paste them onto your terminal and the whole process will run so make sure that you check the block out and just get the code from there make sure that you check the blog out so yeah from the blog copy and paste these line of code and then just press enter and this will take a little bit of time i'm just typing this take a little bit of time and all these libraries and everything will be installed onto your build folder of your opencv let's press enter take a little bit of time the next thing that we're going to do after building the build folder and everything inside this is just type in make dash j4 what this is going to do is compile the entire things all the libraries and just start running opencv onto your raspberry pi this whole process of make j4 just compiling everything will take about 30 to 40 minutes so make sure that you're just sitting through it because sometimes what happens is that at 63 percent or something make j4 can give an error if it gives an error there's nothing to worry about just after that error just type in make dash j1 what this is going to do make j1 uses a single core it takes a lot of time much much more time than make j4 but it's stable so just make j1 and it will just do the entire process that make j4 does also disclaimer do not use make j1 first and then just do the entire process make sure that you're just typing make j4 first and if and only if it's giving an error type in make j1 for me while i was testing this whole process out make j4 did not give it might give and if it does type in make j1 and if it does not just carry on with the process it will just complete the process on its own so just type in make dash j4 and press enter and entire process starts just compile and open cv will start running after the whole make j4 process is done what you have to do is just download another simple small little library by just typing this kind of code onto your terminal and it'll just download all these libraries very fast and it just takes no time so what you have to do is just type in sudo apt-get install lib open cv dash dev space python open cv and what it's going to do is just install and download all these libraries python libraries and once the whole python libraries are downloaded and installed and done what you have to type in is python and just press enter and just wait for a little while and once that is just type in import cv2 and once you press enter the next line will just come like this as you see on my screen right now and opencv has successfully completely installed and downloaded onto your raspberry pi and you can start working on all the projects that you wanted to through opencv onto your raspberry pi and that was it that was a comprehensive tutorial of how to install opencv onto your raspberry pi using cma if you enjoyed this video and if you thought this video was informative and helpful give this video like and comment down below if you want us to make any projects with opencv we're currently in the process of making a project of face detection using a raspberry pi and open cv that video is gonna come really soon so subscribe for that if you already haven't and that has been it thank you so much for watching we'll see you next time
Info
Channel: Robu.in
Views: 61,450
Rating: undefined out of 5
Keywords: Robu, robu.in, robotics, electronics, diy, diybot, embedded systems, electronic engineering, drone, diy drone, hexacopter, robocon, mechanics, engineeringprojects, engineering, electronic engineering project, electronic components, electronics projects, opencv, raspberry pi, rpi, raspberry, pi, open, cv, image processing, face detection, image detection, tutorial, step by step, cmake, raspberry pi os, headless display
Id: rdBTLOx0gi4
Channel Id: undefined
Length: 12min 58sec (778 seconds)
Published: Thu Apr 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.