L-3 Install OpenCV 4.5 on NVIDIA Jetson Nano | Set Up a Camera for NVIDIA Jetson Nano

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone this is arohi and welcome to my channel so guys this is the third video of Jetson Nano playlist so in my very first video I have explained you how to write the operating system image on a SD card because Jetson Nano accepts the operating system through that micro SD card only and then we put our machine boot our uh this Jetson Nano for the very first time and for that we have used HDMI screen and USB mouse and this keyboard and network connection and I've used ethernet for that okay this is what we have done in our first video and in second video we have learned how to use Jetson Nano headless that means how to use Jetson Nano remotely and for that I have explained you how to use xrdp and VNC to use the Jetson Nano remotely and I have also explained you how to use Wi-Fi all right this is what we have done till now today in this third lecture I am going to explain you how to create your python environment and then how to install opencv I will show you each and every step so that you can you know follow all those steps and you will be able to run the opencv successfully on a python see uh this python okay and guys after that I will talk about the camera I will show you how to use CSI camera and a USB camera we will test that okay so let's begin so we are starting with opening a terminal and then now we'll check the python version so the python version is this now let's check the Python 3 version so because we don't want to use the python 2 we want to use the Python 3 and this is the Python 3 version which you have and guys this these two pythons you will get when you uh you know when you boot your Jetson Nano for the first time all these things are already there these things are by default okay so we have these two python versions already now what I want is I want to create a separate environment and then I want to work under it because I always prefer to work in a separate environment okay so let's start by doing that and first thing which I'm doing is this is the command so guys I am not executing this command because I have already performed this step but what I'm trying to say here is that you have to install the PIP okay and this is the command which I have written over here so we want to use the Python 3 so we need a pip version which works with Python 3 so that's why we have written like this so guys I will mention all these commands in the descriptions section you can copy the commands from there and you can execute it okay now let's execute the second command now my second command is this okay now what this command is I want to install virtual EnV now virtual EnV is a tool to create isolated python environments right so we want to create a separate environment so what that we need this um uh package so that's why I'm installing it okay once you execute this command after that now you want to create a separate environment and this is how you create a separate environment so what I have written is see see this command what I have done is Python 3 virtual environment and then this is my environment name that means after executing this command you will get one folder with the name of EnV and inside that folder you will have all the files and folders which are required for this python environment okay and you 'll see here I have mentioned this also system site packages what this means is that we want to install all the default packages which you know came when you install the Jetson Nano image for the first time so that Jetson Nano image have some default packages for example opencv is there okay and you want to just pick the opencv module from that default uh settings and you want to put it in your environment okay so this is what it means that we want to use the default packages which are already there uh in our Jetson Nano image okay so this is what it means when you enter after that you will get uh let's do LS and you will see a EnV folder so where is my EnV folder here so this is the EnV folder which we got after executing the above command okay so now we have to activate the environment so for that I have pasted this command Source EnV is the folder name bin and activate now you can see here that the environment is activated now we have a separate environment okay now the next thing is to this is how you can guys um create your separate environment now the next thing is to install opencv right now uh to install opencv we are going to follow a long method we it will take some time but I can assure you that after following all those steps your opencv will work properly with uh you know and it will be compiled with Cuda okay everything will work fine so first thing is that we will install the opens uh opencv from its source okay and guys one more thing I want to tell you that when you use opencv okay by default the opencv which is there in the adjacent Nano image that opencv comes you know don't have any Cuda support okay and what we want is we want to install the opencv with Cuda support so that we can use you know um a deep learning applications easily all right so for that what you can do is first of all you can check the version of the opencv which you are using so guys in my case I have already performed all these steps so I will get the this version this is the version which I have installed by myself the previous version was 4.1.1 okay the previous version before doing this uh opencv installation I was was having 4.1.1 opencv version after installation now this this is the version which I'm having and this is Cuda compatible okay so now I'll show you the steps to get this version okay so what we need to do is first guys you need to create a swap file right now what is this swap file uh guys swap file is very important because this the Jetson Nano which we are using this is 2GB or 4GB right the physical memory is 2GB or 4GB and sometimes when you install applications or you work so you will get a error out of memory running out of memory right so we need to create a swap file so that we can overcome this issue all right so how you can check your this swap memory just write free space hyphen Edge and over here you can see in my case the swap memory is this all right but this is again I got this memory after creating a swap file before creating the spap file this is the memory which I was having right so you can see that previously I was having very less memory but after creating a swap file this is the memory which I got now how to create this swap file so for that there are few steps which you need to execute step by step so let me show you the steps so the first step is guys you can see uh this image over here you can see there are four or five commands which I have executed again I'm writing all these commands in my description section you can copy these commands one by one and paste these command one by one on your terminal paste First Command execute that command and then paste the second command and then execute it this is how you have to do right so after executing all these five or six commands you your swap file will be created and then again perform this free Edge okay so you will see that before creating that swap file over here the memory was not very much but after creating a swap file your memory over here will be increased okay now we have a more fam more memory so now our application will not be crashed Okay so this is the thing you created your swap file and after that you need to reboot your PC all right so we have created a swap file now the next step is so guys there are few dependencies which you need to install before installing the opencv so there are some you know third parties software so third party libraries which opencv use so we will install all those libraries first okay and guys sometime what happened is the the commands which I'm going to show you sometime it might happen that you already have some of those packages with you on your PC already on your Jetson Nano already but I will suggest you that execute all these steps all these install all these Library ones because um because sometime because of missing any one package you will get a problem okay so so we will install all these commands one by one so you can see here is the list of command and using all these commands one by one in your terminal it will take some time obviously because there are 10 or 12 different commands so you have to execute all these commands one by one in your terminal and then your Jetson Nano is ready to install the opencv okay so now let's install opencv so for that guys first you need to download okay let me write here give me a second please okay let me cancel the process because I already have this command so this first of all we are downloading uh opencv 4.1.4.5.1 okay we are downloading it and then after that we will download the next thing which is this the next command is this opencv contract okay so we have downloaded these two zip files so once you downloaded these two files you need to unzip them and you can unzip them by this unzip the folder name and then the unzip and then the second folder name okay this is how you can unzip them after that you need to rename those directories so done is let me paste this command over here okay so this is the command which I have done so guys in my case I have once I performed all the steps I've deleted all the you know extra files and folders to clear up the space so that's why uh I'm getting this no such file or directory error in your case you just need to do this move this file to a this folder okay and then in the same way what we will do is there is one another folder also with the name of opencv contract so we'll paste that also this is the folder now we are moving the content of this folder to this okay so now our opencv is in this folder now and opencv contrib is in this folder okay so this is what you need to do after that remove the zip files which you have because it will clear the space remove the files like this remove opencv dot zip and in the same way remove opencv underscore corn chip dot file okay so this is the these are the steps you need to do okay so once you've done that now next thing is you need to enter in opencv folder okay let me copy and paste it you need to again in my case I'm getting this uh directory issue because I have performed all these steps already what you need to do is you need to enter in the opencv folder the opencv folder where we have just you know moved the content of our opencv 4.5.1 okay so we are entering in this folder once you enter in that folder The Next Step would be make directory and then build you need to make a build directory once you make the bill directory then you need to enter in that build directory okay once you enter in the build directory now guys this is the command I'm showing you right this is quite a big command so you need to copy this command and paste it over here okay and then enter after that you need to do this make space hyphoon j4 and execute this command guys this command will take around two hours to complete the process right and if this commands work successfully and this is what you'll get and you can see here uh what you will get finally if this process is successful this is this is how you will see the screen okay so after this once you've done that this command after that now you can see that we have successfully built this opencv right now what we will do is let's finish this install and remove all the extra things which I've told you like I have after completing my whole book I have you know deleted all the extra things to clear up the space now you will also do the same process do you need to follow okay these are the steps okay these are the steps which you need to follow one by one on your terminal so you can see that we are removing the opencv uh four and then we okay these are the steps okay just perform all these steps one by one and finally once you've done all these steps now we will check whether we have the latest the version which we want to install whether we have that version or not okay so for that write Python 3 okay just give me a second please Python 3 and enter now here you will write import CV2 input CV2 and then enter after that CV2 dot underscore underscore version underscore underscore here you can see that we have the version the version which we want to install okay so we have successfully installed the opencv now guys the next thing is as I've told you that we want to install the opencv which is uh Cuda compatible now how to see that so for that guys what you can do is you can install this J Top okay J Top is a tool okay you can just install by writing this command okay just write this command I'm pasting here okay this is the command sudo HP install you uh Jetson stats okay install this once you install that you need to reboot your PC and after that when you open your terminal again just write J top and enter when you do that you will see the Jetson starts over here and from here I'm clicking on this six info and you can see that opencv 4.1 4.5.1 compiled Cuda yes that means we have successfully installed this opencv 4.5.1 with Cuda compatible okay now if you want to come out just click on quit and you play out okay so we have installed the opencv now now next step is now we will see how to connect a camera to a Jetson Nano so guys for that you can see this small video it's the very first thing is make sure the Jetson Nano is completely off and the power is not connected to it okay and then take the camera and then lift the plastic tabs of the CSI connector okay you can see that there is this is CSI connector and you need to you know these are the plastic tabs you need to lift them up you will just press it like a press it and it will open okay and then put the ribbon cable fully into the connector and the blue marking should face towards the outside of the board it should face towards you okay and then hold the ribbon cable inside that connector gently and push down the plastic tabs and your um this camera will be inserted uh into your Jetson Nano okay and now we have our camera inserted now guys the camera which I am you using is let me show you that camera so this is the camera which I'm using okay so you can see this is the ribbon cable and this is the blue area it should be towards you outside the circuit and uh yeah this is the camera which I'm using all right so now after that now once you've done that now we want to test our camera so for testing the camera what you need to do is just copy this and paste it here and enter and guys if you are getting this kind of output that means your camera is inserted your camera is connected with the Jetson Nano okay now if you if all the cameras which are connected with your Jetson Arrow so right now I have connected to camera one is a CSI camera which I've just shown you right and the other one is my USB camera my web camera so I will show you how to see both the cameras so for that just paste okay guys I just took it out you will execute this command and after that you will see this output okay you can see that we are getting both the we are getting two different uh links one is video Zero and video One video Zero is for my CSI Camera and Video one is for the USB camera okay now we let's say we want to uh capture we want to Let's test the camera okay let's click the picture let's open a camera and for that this is the command which I'm using so when you will execute this command and you will press enter you will see your image okay so yeah you can see here okay so this is how this works in by control C you can um cancel it and after that now if you want to use your webcam then how will you use that for that you will use this command this command guys okay just a minute so this is the command first camera Source zero this is for web camera and cap hyphen Dev hyphen node equals to one why I've written one over here so guys remember uh just a minute back when I have shown you the list of cameras over there uh this Dave 0 uh video Zero is for my CSS CSI Camera and Video one is for my uh this camera USB camera so that's why I've written one over here and you'll press enter and you will see the output like this okay so yeah guys so this is how you can use the cameras so guys in my next video I'll show you how to use this camera with my python application so thank you for watching
Info
Channel: Code With Aarohi
Views: 28,121
Rating: undefined out of 5
Keywords: Jetson Nano, Jetson Nano Developer Kit, Nvidia, AI, Artificial Intelligence, Machine Learning, AL, Deep Learning, AI Applications, Aarohi Singla, Akminder, Neural Networks, Convolutional Neural Networks, Object Detection, Jetson Nano Headless, Jetson, OpenCV, Python, CSICamera, JetsonNano
Id: P-EZr0zy53g
Channel Id: undefined
Length: 23min 2sec (1382 seconds)
Published: Mon Jan 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.