spmallick / learnopencv

Learn OpenCV : C++ and Python Examples
https://www.learnopencv.com/
20.68k stars 11.52k forks source link

How to use OpenCV DNN Module on Windows with c++ #824

Open kabiri opened 1 year ago

kabiri commented 1 year ago

Hello How to use OpenCV DNN Module CPU only on Windows with c++ How to install and config it?

brmarkus commented 1 year ago

Other than MS-Windows and C++ - do you have something specific in mind?

Have you tried following e.g. "https://docs.opencv.org/4.7.0/d3/d52/tutorial_windows_install.html" (for e.g. version v4.7 or any other version to select from the drop-down field in the upper-left corner)?

Do you need or have to build from source on your own?

Do you need a specific backend (like for NVIDIA-GPUs or Intel-GPUs/CPUs/VPUs, like using OpenVINO)?

When it is about an Intel-based environment (like CPU, GPU, VPU, FPGA), would it be possible for you to use OpenVINO (build from source or pre-built) (in the latest versions of OpenVINO there is no OpenCV contained anymore, but providing instructions for how to get it, how to install, which version to use as a specific version of OpenVINO is validated using a specific version of OpenCV)?

kabiri commented 1 year ago

I built OpenCV 4.7 on Windows using CMake for GCC. However, I couldn't build Caffe. I installed TensorFlow on GCC and successfully ran a test program with it. But when I run the examples from this repository, the program gets stuck at the net.forward line without any error.

That's why I installed Microsoft Visual Studio 2022 Community and I want to install and configure OpenCV 4.7 for it. The reason I asked these questions here was to make sure that I have done everything correctly.

Since I don't have an NVIDIA graphics card, I want to use DNN with CPU.

brmarkus commented 1 year ago

Could be a version conflict (e.g. version and/or supported layers and/or operations of the model) between the used framework (Tensorflow) and the model.

Maybe additional logs during loading of DNN might help via enableModelDiagnostics(): https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga9c06b170a462e97b413163aadb9869f9

Not every example documents the needed requirements (or documentation or requirements.txt is outdated), or sample-resources (like model-file) (like "the model-file X was created/trained/exported using Framework Y in version Z").