OpenCV C++ Install, Build, Run using VS Code and CMake (Debug and Release)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] all right in this video I'm going to show you how to set up build and run your open CV C++ program using vs code and cmake so we will start off by showing you how to install cmake install open CV set up your environment variables go over the cmake list .txt file that you need go over a simple open CV program in C++ go through the configure step do the build and debug build and release and modify the program and rebuild if you're new to my channel I teach open CV computer vision python C++ git Ross 2 solid works mechanical design and I have a GitHub that goes along with it so subscribe to learn more so first off we're going to install cmake so we'll go to the cmake website site so when you go to the cmake website I'm on Windows the 64bits so if you go here you'll see under the binary distribution you see the windows x64 installer so go ahead and run that and install your cmic next up we want to install open CV so for me I'm installing 4.8.0 so if you go to the website and click on Windows you're going to see the exe file and go ahead and run that so for me I am running it in um saving the file FES in the opt path so for you you could choose your own path so if you go to the website here you're going to see um here you have the open CV you have the different versions and if you click on the window sign the download will start so once you download that you're going to see you have the open CV folder and this folder has your build files you'll see you have the bin folder here and the lib folder which will contain the necessary files that you need when you're actually running your open CV program next up we want to set up our environment variables so for that you want to first we need to set a variable called open CV dur and you want to evaluate the value to the location of your build folder which we were just at and this is required for this specific line in our cmake list which we'll go over in a little bit and also you want to add these three things to your environment variables for your path so to get to your environment variables hit the Windows key and type system uh environment M and you can see this pop up so go to environment variables and you see I have declared my variable and value here and if you take a look at our path here you can see we have our cmake bin we have our open CV bin and our open CV lib now let's go ahead and take a look at our cmakelist.txt so for this cmake list it's a pretty simple file so we have a cmake minimum required and this is a minimum version that the cmake is using you have a name of your project which we're calling open CV example you want to find the package for open CV and this right here is going to find our open CV package you want to include the necessary directories here want to add the executable for the file that we're using and then we want to link the open CV libraries with this target link libraries command now let's take a look at our simple program for our open CV program so we have an in main we have a image path here which I'm calling Tesa Peg here I'm doing a CV read so this will read in the image and this is going to show the image and this is going to be some weight key to weight for the users to press something now that we have our program and our cmake list.txt file we could go ahead and run the configure step so first thing you want to do is make the directory build so I'm going to go ahead and run that make directory build so this created our build directory here and I want to run the c-b and the build folder so this will be the configure step so what the configure step is you can see it's building for visual Studio 16 2019 and the select the windows SDK version is this so it's going through looking through some compilers and then the build files is going to be generated into this build folder so you can see here there's some um Solutions file you have some um cmake cache file and some project files which we will then later actually use it to build so to build in debug what we want to do is run this command cake-- bu. build so if we go ahead and run this this will build our folder so you see this build our project in debug here so here we have the exe file open CV example so we could go ahead and run that now so if I copy this command build debug and then the exe location and run it you see it shows the picture of the Tesla so you have your program up and running now if you want to build in release what you want to do is run this command here build uh you want to add the special command here config release so if I go ahead and paste that you see that new release folder is now showing so this release here has a special another exe file which we can then run to run and release so if I go ahead and copy paste that and now I'm running it and release which is supposed to be much faster now if you want to modify and rebuild your program what you want to do is um just change the code in your main so here let's say I'm doing my Milky Way picture now and then if we come back here all we need to do is Rerun the build step so here I'm going to go ahead and rebuild so you don't have to do the configure step again just only the build step so after you do the build step you could run the exe and then now you see we have our new file up and running okay so if you found this video helpful give a like And subscribe and I'll see you in the next [Music] one [Music]
Info
Channel: Kevin Wood
Views: 9,260
Rating: undefined out of 5
Keywords: computer vision, visual studio, visual studio opencv, opencv visual studio, opencv c++, c++ opencv, opencv tutorial, opencv c++ tutorial, install opencv, install opencv c++, install opencv c++ visual studio 2019, setup opencv c++, opencv c++ setup, how to opencv, opencv guide, opencv visual studio code, opencv visual studio code c++, opencv vscode, opencv c++ vscode, vscode opencv, opencv c++ install, opencv c++ install windows, how to use opencv in c++, opencv
Id: CnXUTG9XYGI
Channel Id: undefined
Length: 6min 5sec (365 seconds)
Published: Fri Jan 05 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.