How To Setup OpenCV with NVIDIA CUDA GPU for C++ in Visual Studio

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome to the new winning this computer vision tutorial in this video here i'm going to show you how we can set up opencv gpu support for visual studio 2019 so in the previous videos we have been uh actually like we've been installing opencv from the source files and with gpu support um so we're both installed and we've configured open source with gpu support by using cmake so i've already went over that those videos so make sure to check those videos out and this would here we're just going to like use what we have already installed and build from the opencv source files and then we're going to set it up here in visual studio code so we can actually like use it in our program with cbs plus but first of all we're going to do a disco server i'll link to it down the description here and you can join the channel chat with about computer vision deep learning ai and so on you can also become a member of the channel here if you want to support the channel more than you're currently doing with a small monthly fee and everything will go to create more and better quality content here on the channel so thank you guys so first of all here we'll go into the file explorer here to actually see where we've installed and built opencv library with the with the gpu support so first of all here we just go into this pc here my local disk and then inside my user directory here so now we can go down here and actually see where we have installed and and build our opencv source files with the deep use board so we've both done it for python and cbs plus and actually when we're using chief of plus we can both use the the build uh to build version with both python and cbs plus but in this example here i'm just going to do it with the folder that i created in the cpus plus video so again if you haven't seen that video and you want to know like how we can install and build the source files with cmake like from from the source files uh with gpu support make sure to check those videos out i'll link to them up here somewhere and you go check those out and then you can come into this video here see how you can set it up in visual studio 2019 so first of all here we just go into this folder here with opencv and then we can just go up to this build folder here where we actually have all our binary files that we that we got from ldx like generating the binaries from cmake and then installing ohmsv with gpus board here on our computer then we can actually just make sure here that we have all of these different kind of like for example uh installation here we can go inside the installation x64 architecture here and then vc16 version here of our home cv and then when we go into here we can see that we both have this pin and library folder here and we need those here to actually like be able to link to to the to the obviously library here in visual studio so first of all here we need to make sure that we're actually like linking or like we actually have this path here in our environmental variables so first of all here we will open up the environmental uh our environment variables here and we need to make sure that inside of this path here we actually like have this directory here or like the path to directory here for our pin folder in opencv so here we just go up here and we click a new one here and then we just type in this path here so in my example here i have it in my c directory or like on my c drive and then i have it in my own user directory and then we have this opencv folder that i just showed you went into the build folder and in this install folder and then into the x64 architecture that i showed showed you and then the vc16 version of omg and then we're going to to take the path here to the pin folder in this example here so when you have added this environmental variable here we just hit ok ok and ok here and now we have actually all the different kind of things that we need in our environmental variables so now we can actually like open up visual studio here and then create a new project and link to the different kind of opencv libraries and directories that we have i like build and install on our computer so here we're just going to create a new product here that we can actually like set up so i'm just going to create this empty project here and we're just going to take this console labs here so basically i have a program that prints out hello world by default so we're just going to hit next here and then we're going to have a name here so in this example we're just going to have ohmsv gpu uh youtube and now we're just going to create this project here so we just have a project from scratch here so now we're opening up a new project here in visual studio and we can just go up here and right click on our project and then we can go down to the properties we're actually going to specify the different kind of like directories for the include files and also the library files and also link to actually opencv files or like files as well and the library so we go down here to the properties and then first of all here we need to go into the vc plus plus directories here and then we need to go up to include directories because we actually need to include the path for our home cv so we go in here and actually hit this edit button here and then we can see that we need to specify in this uh in my user directories and then in the folder wherever actually like build the source files from opencv then we need to go into the to the build one and then we need to go into include files and this include file here is actually inside the install file so i'm just going to specify that here install and then include because if we're going to the directory here again in our c drive in my local file here and the users and we're into my local here we go down to om cv and then we're going to build then we can see that we have access like this include here but we need to go into this install where we actually like installed ohmsv on our computer with gpu support so we're into this install file here and then we can see we have this include folder here which tags like in an include folder that we need to link to or like you need to specify in this include directories here so i've done that here we can just press ok and then we need to go down here to the library directories and then we need to specify where our library files are for umcb so again we just go in here and we hit edit and then we just specify the path here to the actual library file here and again we're inside the build folder and the installation folder and then our architecture on our computer and then we have the version here of opencv total vc16 here and then we specify the path here for our library files that we have in this path here so in the environmental variables we specified the pin folders but inside of the projected properties here we're going to specify where the library files are for opencv now we're going to just hit ok here again and we hit apply so we actually just apply these things here to our project so the last thing here that we need to do is that we go down to the link here and actually link the library files or like a library file from opencv to our project here so when we run our program we can actually use the methods and stuff like that from home cv so down here in the linger we go down to the input here and then we just need to specify the opencv world file up here in the additional dependencies so we'll just go up here again and hit edit we need to specify this opencv underscore world and then the version of opencv that we are running on in this case here i have installed and build almost every from the source files uh with this version here so 4.5.2 and then we don't have a d here because we're going to run this program here in release mode instead of debug mode and then we have this lip file here so we actually have this additional pet dependency which is the library for a file for opencv that we're going to link to here in this in the properties here so number hair acts like everything set up we both have the additional dependencies and we also have the directories for our include directory and also for our library directories here as well so now we have everything set up here in the properties and we didn't can then just hit ok down here we need to go up here to the top and make sure that we're in release mode instead of debug mode which is default when we just open up a new project here in visual studio and then we also need to specify the architecture here so instead of x6 86 here which is the default we choose this x64 here because this is the version that we have built and installed almost to be on so now we both have release here and we have the architecture here which is x64 then we can just copy a small uh program sample here so we can actually like just print out the information about the the device that we have actually connected to a computer and we're going to include the different kind of like opencv 2 modules that we can then use later on so i'm just going to cover this this code in here and i'll link to it down the description in my github so you can just go to my github copy paste the same code here and see if it works in visual studio code or like non-visual only in visual studio here on your computer so first of all here we're just going to include iostream as usual when we use cbs plus and then we're going to include opencv 2 here and then the dnn module that we're going to use throughout other other tutorials here and on this channel here we're going to use the neil network module that we have with omsv for neural network inference and then we're just going to uh specify include the opencv here with the impro and the hide ui and then we have iostream here again which we should not have and then we're going to include the core here of code as well so this is actually like where the kuvda functions are that we're going to use here and this example here we're just going to print out the cuda device info that we have on the serifs element uh because i only have one gpu here connected to my computer and then we're just going to use these namespaces here so we don't have to type out a cv colon call line cuda to be able to run this function here so now we can see that we don't get any uh we don't get any errors here we don't get any red lines under any of these include directories here and also this print code of in device info here we can actually find that methods in the modules that we have from opencv in our source files so now we can just go up here to the windows logo windows debugger and we can just run this program here and see the information here about our cuda device that we have connected to our computer so if we go up here we can actually see the different kind of information that we also got in the previous videos where we've installed and built almost these source files with gpu support from scratch with cmake so we get the exact same information here because we can this is just to verify that this actually works and it is video here i just wanted to show you how we can set this opencv gpo support up here in visual studio where in the other videos i set it up for c plus plus in visual studio code and i set it up in python for visual studio code as well so it's just to show you guys like how we can use different kind of ides and text editors with opencv with gpu support as well both for python and cbs plus so we can see here that we get the device count here which is one and we have the device zero here because i only have one gpu and we can even see the name here of the gpu so i have an nvidia geforce gtx 1060 with six gigabytes of ram and then we also get some other different kind of information here about our gpu so now we can actually verify that we have set up opencv with gpu support here in visual studio and then we can use all the different kind of methods from uh from this core core cuda module here and then we can actually use cuda to do neural network inference in this dnn module here as well so we can do a lot of different kind of cool things with gpu support for opencv and it's really fast and efficient when we're running our methods and programs and algorithms with gpu instead of cpu and it's up to 10 to 20 times faster so we're going to create some really nice and cool videos where we're going to test how fast the gpu is actually like this and we're going to create create some programs where i'm going to show you like how we can actually use the gpu and this cooldown module here in opencv so thank you guys for watching this video here and remember to subscribe button and bell notification under the video here and also like the video if you like the content and you want more in the future i'm currently doing a deep learning tutorial where we're talking about like how we can create new networks from scratch we go over the basic stuff about neural networks we train it on a data set and then we do an uh interference or we're trying to do predictions on data or like images that the neural network hasn't seen before then we're going to compute combine this computer-based tutorial with deep learning we're going to use the dnn module here in opencv to actually like run neural network inference on gpu so we combine all different kind of things that we went over in all the tutorials throughout this channel here so it's going to be very nice and really cool and we're going to create some really nice applications so i'm going to link to the deep learning tutorial up here or else i'll just see in the next video guys bye for now you
Info
Channel: Nicolai Nielsen
Views: 13,910
Rating: undefined out of 5
Keywords: opencv c++, c++ opencv, opencv python, python opencv, opencv gpu, opencv gpu c++, opencv gpu python, gpu opencv, opencv cuda, opencv cuda c++, cuda gpu c++, opencv source code, build opencv source files, cmake configuration, cmake opencv, cmake opencv c++, cmake opencv gpu, computer vision c++, opencv, NVIDIA, NVIDIA Cuda, NVIDIA cuDNN, The Coding Library, opencv nvidia, cuda opencv, cuda opencv c++, cuda c++, cuDNN, install opencv c++, build opencv c++, install opencv
Id: WnRAcpWqR7I
Channel Id: undefined
Length: 11min 14sec (674 seconds)
Published: Tue Jun 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.