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

preview_player
Показать описание

I installed visual studio 2019 prior to this video, so you may need to do that as well if you are missing some compilers.

FAQ1: I am seeing the following error
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.

Could not find a package configuration file provided by "OpenCV" with any
of the following names:

Solution: Make sure you set up the environment variables described in the video. Remember to restart VS Code!
Variable: `OpenCV_DIR`
Value: `C:\opt\opencv\build`

FAQ 2: Compiler not found.
Solution: You may need to install visual studio to download the compiler.

0:00 Introduction
0:56 How to install CMake?
1:13 How to install OpenCV C++ build files?
1:57 How to set up your environment variables for OpenCV and CMake?
3:20 How to make a simple OpenCV program in C++?
3:39 How to configure the build?
4:28 How to build and run your OpenCV project in debug?
4:54 How to build and run your OpenCV project in release?
5:20 How to modify your program and rebuild?

Thanks for watching! If you found this video helpful, please like, subscribe and share:

Social:
Рекомендации по теме
Комментарии
Автор

Thank you !
I was struggling with getting started with Nicolai nelsons opencv tutorial in vs-code and this video sorted me out.
Nicolai has amazing tutorials on his channel but the getting started with installation hasn't worked out for many.

I'm on my way now thanks to this tutorial, so cheers and a big hug.
Liked and subscribed !

behrampatel
Автор

Trying to use OpenCV in C++ for two days for an assignment, 2 days of work couldn't do it and now within just 5 minutes, it is done. Thanks

alihanyalcn
Автор

Thank you for this video it was really helpful and also I want to mention a possible solution for the other viewers that you may need to have visual studio CMake packages in order to run.

Alper_Cetin
Автор

Watching sir. This was helpful! 😊❤🎉 great video as always!

genelyngorospe
Автор

Hi, Thank you for the tutorial. I followed your process, and have a problem. Could you give me some advice?

After editing Environment valriables, like OpenCV_DIR = C:\opt\opencv\build, and some path variables,
I wrote CMakeLists.txt as your guide, and when running configure, got error message like:

CMake Error at CMakeLists.txt:8 (find_package):
Found package configuration file:



but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND.

To handle it, I changed OpenCV_DIR = C:\opt\opencv\build\x64\vc16\lib, and It works in configuration, but could not success build. Thank you in advance :)

ipkrjoc
Автор

I love watching your videos i can learn alot

realblythe
Автор

excuse me, is there a place I could find the code and readme you used in the video? Thanks!

Leo-eung
Автор

Doesn't work, as other people said I think you take for granted some steps.
I tried debugging and got an error in
find_package(OpenCV REQUIRED)
when executing the cmake
This is because there is no compatible binaries.
Have you installed VS2022 before?

uber-forex
Автор

Hey quick question when I run cmake -B .\build\, I get this its building for ninja rather then visual studio any Idea how to fix this?

-- Building for: Ninja
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

denzeldelnawaz
Автор

I have a strange problem: once i do the cmake .\build\ command, it fails and outputs this:
cmake error at CMakeLists.txt:8 (add_executable):
No SOURCES given to target: OpenCVExample
I have changed all OpenCVExample to my project name (called test for now) and it still says that it targets OpenCVExample.

nicolastraglia
Автор

Where is this CMakeLists.txt file?? Do I need to create it in my working directory??

vaibhavchaudhary
Автор

Hi, Thank you for the tutorial. I followed your process, and have a problem. Could you give me some advice?

Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable.

abdurahimbaşaran
Автор

Thanks for sharing and nice work. I just wonder if it is possible to debug OpenCV code with the pdb file.

joseantoniogarciaacosta
Автор

why we use visual studio rather than MinGW?why we can not use opencv on vscode like ubuntu?

yyu
Автор

i am facing an error while creating the main.cpp error: cannot open source file "opencv2\opencv.hpp" how can i fix.?

devakirajesh
Автор

I have an error: CMake error: cmake_cxx_compiler not set, after enablelanguage
Please help

slavisafrombosnia
Автор

Can you show us how to run the debugger and use breakpoints with this?

myrontruesdale
Автор

I'm gonna watch, if your video solved my problem, i will subscribe, and maybe gonna watch your full opencv playlist

letsgetcopyright
Автор

And Thanks a lot, My problem is solved, I wanna thanks a lot, and next i wanna press the subscribe button and after that i am gonna watch your playlist.
Now don't worry you will see my name on your multiple videos, and maybe some other people that i'm gonna refer.

letsgetcopyright
Автор

Got the same error as @genelyngorospe72. Too bad most of your videos are great. And yes I tried restarting VS

pademo