OPENCV 4 + CUDA on Jetson Nano

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello it's Jim from jetson XCOM on today's show we are going to build open CV for with CUDA support for the Nvidia Jetson nano developer kit there are several reasons you may want to build open CV from source some of the applications that you use may require a certain version that's one reason another reason might be that you are developing a new application and want the latest and greatest a third reason is that you may want CUDA support there are several resources on the web that can help you the canonical for series build is from Nvidia itself this is from one of the engineers I will leave references for all these in the article linked in the description below so in the jep repository we see install OpenCV 4.1.1 this is frequently updated with the latest version just take a look at it it's pretty straightforward it's pretty much just compile it and go you'll notice here that they use the cuda architectures of all the jetsons 5.3 is for the Jetson Nano and Jetson tx1 6.2 is suggests in DX 2 and 7.2 is xavier another resource is Michael Dickens you probably recognize this from the Jetson forums he's someone who knows what's up and I like his daugher if we go to the Nano build OpenCV repository you can see that there are scripts here to build OpenCV and that's version 4 you can pass as a command line parameter the version of OpenCV that you want to build and you can see that this is a much more formal script now if you want to build a 3x version I suggest you go here now why would you want to do that it turns out that some applications require 3x so things like cafe I may be mistaken but I believe Yolo also requires 3x is a pretty excellent explanation of all the flags that you would set especially for a cafe build if you are doing a type of machine learning on the Jetsons you should read this blog it's way excellent and now the question you ask is why does Jetson hacks have an open CV for build the answer is there's a secret build flag and I want to share that with you what the build flag allows you to do is build a package that includes everything in the library you can take that package and more easily install it on other machines let me know in the comments below if you'd like me to share one of those built packages I should be able to make a video and a blog post on how to use it let's switch over to our web page on the Jetson hacks Nano account on github there is a repository named build OpenCV let's clone that repository and switch over to that repositories directory let's take a look at our build script get ready for the magic flag this script is very similar to the previous build OpenCV scripts that we've done over the years we are going to build for the Jetson nano so our architecture is 5.3 we are going to install it in slash user slash local we're going to put our OpenCV source directory at the home directory and then here's a little tip if you are trying to build this on an SD card you should set the number of jobs to one that tells make to only use one job when it goes to build this nothing's built in parallel if you are compiling on a USB Drive it's better to you use some parallel threads we just set it to the number of CPUs on the Nano this is for and then here's the magic part package OpenCV if we set the package OpenCV flag on it we'll build a binary with the installer that will install the package it's all packed into one thing it's about 50 megabytes or so and that way you don't have to rebuild it every time you go to a new machine life becomes simple by default we leave that on it only takes a couple of minutes to package after you have built OpenCV down here we install our dependencies since we are building for Python we just built for Python 2 and Python 3 we add in GStreamer support and then we go and grab the opencv repositories almost all the opencv releases have little niggles with them that you have to take into account in 4.1.1 there's an issue with the eigen library so we fix that up that was the same issue we had up here with this OpenGL header patch if you compile with opengl on then you need to apply this patch I believe the issue is Jetson specific after the dependencies are loaded on the machine that we run CMake you can see here all of our different flags we are building in release with cuda on we set our architecture we use fast math video for linux gstreamer we use QT here and opengl OpenCV python to python 3 and if we include the package flag that's what this environment variable expands to after C make we start building you should use a swap file with this build know 1432 point-to-point one has that included when you go to make this you will run into an issue with memory more than likely you will run out of physical memory and fill up your swap file there will be some thrashing going on and eventually it will restart itself that's what this second mix down here does we just run one job and typically it's in the Python area that this runs into issues once it's through building then we installed after the installation we pack it up and then we run a sound Adi check here with Python let's go back up to the readme here's a build instruction to use let's grab that and now because memory is tight we'll close down this browser for the purposes of this demonstration I'm going to run the system monitor now we're ready to start our build password and off it goes this will probably take about two and a half hours if you're building on a USB Drive [Music] this word [Music] installation complete in real time that was about two and a half hours you can see here on the screen some of the results of the build remember that we saved them to a log file we want to make sure that open CV for does not get overwritten by other installers so we place it in slash user slash local let's reboot the machine just to make sure everything cleans up okay we're back let's take a look at our build let's open up Python let's import CV - that's the opencv library 4.1.1 little wonders never cease we can also get the build information of course this gives us more information about our build the version c make version that we used hardware features the command lines that were used for the C and C++ compilers linkers Flags things of that nature here are the open CV modules that we built this will give you a sense of the CUDA functions available we see up here CUDA filters CUDA optical flow CUDA warping and then we used QT as our GUI GUI GUI GUI then we have some information about our media i/o our video IO you see that we include GStreamer support and video for linux the cuda version that we are using is 10.0 and our GPU architecture is 5.3 and that's for the jets and nano and Judson tx1 we're using si UD n N and that's version seven point five point zero we built support for Python 2 and python 3 let's get out of this there is a simple sanity check here the program is written in C++ let's compile it we'll grab this wander over to the examples directory paste it in compile it and let's run it although it should happen is that we get a camera output there we are and microphones in the way but you know who else is here yes Bruce is here let's close this up and then we have a simple application that does County detection in Python let's run this in Python 3 okay it looks like it's delayed about a No three or four hundred milliseconds I noticed that on all the builds whether it was from this script or the others and if you are unfamiliar with this application the top left corner is the original RGB input we convert that to black and white and then we run a Gaussian blur on it and then we convert that into our edge detection it's interesting because you can actually see the gills you can also set the detection up you can see the thresholds change here a little bit they go from very silly to almost nothing it helps you with lighting conditions and such it's up alive and running I hope that you find this video useful you should be able to now go in and take the script and modify it for your purposes if you liked this video give it a thumbs up and if you have not already please subscribe and as always thank you for watching
Info
Channel: JetsonHacks
Views: 49,030
Rating: undefined out of 5
Keywords: JetsonHacks, Jetson Nano, Jetson Nano Developer Kit, NVIDIA Jetson Nano Developer Kit, OpenCV, OpenCV Python, Gstreamer
Id: tFGZjVUR_Ck
Channel Id: undefined
Length: 13min 27sec (807 seconds)
Published: Fri Nov 22 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.