AI on the Jetson Nano LESSON 10: Installing OpenCV for Python 3

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys this is Palma quarter from top tech boy comm and we are here today with lesson number 10 in our incredible new tutorial series where you are gonna learn artificial intelligence on the Jetson nano I will need you to pour yourself a most excellent mug of iced coffee and I will need you to get out your Jetson nano gear what you don't have your gear yet look down in the description I've got links to the identical hardware that I am running in this tutorial series and if you want to play along at home it does help if we are on identical hardware also want to take a second and thank you guys and give a shout-out to you guys that are helping me out over at patreon your support is a huge encouragement to me and those of you who might be interested in that if you will look down in the description I have a link to my patreon account think about going over there and hooking a brother up ok enough of this nonsense advertising my patreon what we are going to do is we're going to jump in and learn something cool today so I will need to get out of your way and tell you a little bit about what we are going to do today what we are going to do is to install the Python package called open CV open CV is the library that we will be using to actually begin the work of doing artificial intelligence on the jetson nano and I got to kind of give you a little bit of background like the first things that we did were just getting the chit jetson nano hooked up and booted and ready to go then last week we installed some really important packages we installed matplotlib which is a library that allows us to visualize and graph large data sets and then we installed numpy and we learned a little bit how to use those two programs sort of an introductory level so when we get into the artificial intelligence you will be familiar with numpy and you will be familiar with matplotlib if you haven't done those yet go back and make sure that you watch that last video ok then the third package the one that we're going to install today is really important and it's called open CV open CV is a library that will allow you to go out and grab a frame from the camera and then take that frame and display it as an image now what's the cool thing about that that's two lines of code like grab the image show the image but between those two lines of code you are in a Python program and you are sitting between the camera in the display and that is where the magic happens and that's where the artificial intelligence happens that's where you can recognize things you can track things you can move things you can do all of this magic between those two steps but to do that we've got to get the libraries installed and we've got to get them installed correctly one of the things that I've tried to warn you from the very first of this series is is that NVIDIA has provided us a very well-thought-out disk image and operating system which we installed in Lesson one and that image has the versions of the software in the versions of the libraries that will allow us to utilize or take advantage of those hundred and twenty eight parallel processors those 128 cores on the Jetson Nano if you go out willy-nilly upgrading from this package to that package in this library to that library very quickly you're going to get your Jetson nano configured in a way that does not take advantage of the parallel processor so I've tried to I've tried to encourage you in this tutorial series that if you're gonna go out and play around and do demo programs and stuff have a separate SD card in this series have one SD card that you don't mess with this should just kind of go through and do the things that we are doing here so what I need you to do is open up a terminal window okay and what I want to kind of show you is is that the Nvidia image operating system image comes with two versions of Python if you just type in Python what you can see is it pops open the default of Python 2.7 now I love Python 2.7 more than anyone did but in a lot of the things that I was doing Python 2.7 became so old that things were breaking they were not supported and there were just things that I could no longer do so I kind of forced to upgrade from Python 2.7 to Python 3.6 now the good news is is that on the Jetson nano Nvidia has included an installation for Python 2.7 which you get by just typing python or python 3.6 which you get let me control d out of here control d out of here you get to python 3.6 by tapping python python 3 ok and you see it pops up we are now in the python 3 point six point eight command line all right so that's good the python three point six is there also remember we when we installed a couple of weeks ago studio visual the code the code OSS integrated development environment for python we set that up to by default use this Python three point six point eight so that is all good so what is the problem the problem is that in the default installation of the nvidia operating system image at least at the time of me making this video that default installation for python three did not have it did not have OpenCV as part of python 3.6 so we need to go in there and install that in the way that we install it is it's a little bit goofy but if you do what i do exactly here it's gonna work for you what you have to do is you have to say sudo apt-get install and then python three apt-get install python three - open CV now this is can take like fifteen or twenty minutes it might go faster for you so I'm gonna hit enter and then I'm gonna pause and I'm gonna come back okay cuz I won't don't want to just sit and talk to you for 15 or 20 minutes so I'm gonna pause and then you let it go all the way down until you get the command prompt and then start again okay I am back mine successfully installed so let's go to Python 3 now don't do this until yours has all finished installing ok [Applause] ok so I'm going to type Python 3 and look at that I am in Python 3 point 6 point 8 now I want to import OpenCV so I can say import CV 2 which is the kind of keyword for open CV so import CV - ok boom look at that now let's look at this cv 2 . underscore underscore version underscore underscore ok 3.2 that this is the goofy thing when we did that installation it downgraded it and it's not the version that we wanted so remember when we were over on Python 2.7 let's look at that again ok so I ctrl D let's just go to Python and then let me say import CV - ok and then let me go see v2 dot underscore underscore version underscore underscore you see Python 2.7 has version 3.3 point so we'll go back to Python 3 and we will again import CV 2 and then we will say c v2 dot underscore underscore version underscore underscore and you can see it downgraded us to 3.2 so we want to be on python 3.6 but we want OpenCV version 3.3 point 1 and when we did the sudo apt-get install it gave us a downgraded version how do we fix this this is crazy but is what we're going to do ctrl D to get out of the Python interpreter we are going to say sudo apt-get install I'm sorry apt-get remove Python 3 - open CV I know you're saying didn't you just install it and now you're uninstalling it it's not for me to ask why it's just for me to show you how to get the version you want on here so now hit enter and you can see it's going in and it says do you really want to remove this yes I really want to remove it and it will take a little while to remove it and so this is the crazy thing okay this is the crazy thing the way to get the right version on Python 3.6 is to do that sudo apt-get install Python 3 - open CV and then do sudo apt-get remove Python 3 open CV and somehow that kind of like wakes it up to where then Python 3 has the right version so let's watch Python 3 ok and now let's do import CV 2 will we get an error no we won't so even though we just uninstalled it we don't get an error now let's look see v2 dot underscore underscore version underscore underscore boom three point three point one now is that the most ridiculous thing that you've ever seen now if somebody really knew what they were doing they could go in and completely build versions and do all this and go through all these scripts and spend a day and you could get the right version that you wanted but this is a way that I found on the Nvidia forums that they were suggesting to do it and it sounds crazy but it works you go to Python 3 you install OpenCV using app get installed then you remove it and then you end up with the version that you want ok let's control D out of that let's also just kind of do a quick thing over here let's go back to our code OSs our integrated development environment I'm going to come up to my file explorer and you can see that we've got kind of two folders we've got this main pipe row folder that we set up then we have this folder that is called basic we have a folder called matplotlib for our graphing programs and then i'm going to come up here I'm gonna select pipe row I'm gonna select that or I'm gonna at least get it like that and then yeah you just don't want to have one of these other ones other folders select it and then I'm going to click on the plus for a new folder and it looks like it is putting that inside of matplotlib which I don't want this is a little bit goofy I think now nothing is highlighted so this should make a new folder in pipe row which it did and then I'm gonna call this open CV the folder yeah that was no good okay I will call this open CV alright and it's a folder so I'm not going to put an extension on it and now I have an open CV folder and now with open CV with open CV folder selected I'm going to come up and I'm going to click on new file and it puts a new file in there and I'll just say open CV intro or I'll just say open CV one dot tie alright enter and now I have a new program so what I want to do here is I want to just say import and what do I want to import I want to import CV too and then I want to enter and then I want to print and I want to print C v2 dot underscore underscore version underscore underscore okay and now to run that I am going to come over here and right mouse click and I'm going to say run Python file in terminal and look at that version 3 point 3 point 1 on Python three and working inside a visual code studio okay so we've kind of got the whole enchilada here where we are now ready to go out and start doing artificial intelligence now I'm going to end this lesson here I will very quickly release the next lesson where we will actually go in and in the next lesson we're going to fire up a camera and we're going to start grabbing frames from the camera and we're gonna start putting them on the on the screen and so really in the next lesson which will be lesson number 11:11 that's where the artificial intelligence really begins in earnest okay you guys if you like this think about giving me a thumbs up again reminds you really appreciate your help over on patreon motivates me to continue to produce quality content think about subscribing to the channel think about sharing this with other people again this is palma quarter from top tech boy comm I will talk to you guys later [Applause]
Info
Channel: Paul McWhorter
Views: 23,299
Rating: undefined out of 5
Keywords: Jetson Nano, AI, Artificial Intelligence, Tutorial, Lesson
Id: 3QYayL5y2hk
Channel Id: undefined
Length: 14min 26sec (866 seconds)
Published: Sat Nov 02 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.