2

I am trying to install OpenCV with contrib modules for Visual Studio 2019 on a Windows 10 machine.

I previously had a working version in Visual Studio 2017, but have been unable to get either 2019 or 2017 working recently.

I have been using CMake to install this, adding the extra modules path before generating. Once I have built the ALL_BUILD and INSTALL files I am not sure of where I am meant to add the libraries and include paths and I have found conflicting results between tutorials and neither seem to work.

My code won't include the libraries and says that it can't open the source file.

Here is my code:

#include <opencv2/core/core.hpp>

The error is:

Cannot open source file "opencv2/core/core.hpp"

I have reviewed the following materials to attempt to solve this but there are no up to date guides to include contrib modules nor any that work

Notebear
  • 21
  • 4
  • 1
    Sorry, but Stack Overflow isn't a place for request "tutorials". However, if you show us your current code, then we could help you with fixing it for work with OpenCV. While adding your code into the question, please follow guideline from the [ask]. – Tsyvarev Oct 19 '19 at 17:34
  • You need to link to the libraries in VS as explained here (around 8:00): https://www.youtube.com/watch?v=l4372qtZ4dc – Grillteller Oct 21 '19 at 12:43
  • Do you get any errors while installing? – Wilf Oct 28 '19 at 20:45

1 Answers1

2

this is a problem of the path to include directory. You can set directly the path in Project setting- C/C++ - General - Additional Include Directory: (c:/opencv/install/include) "Just example". Follow the picture. This will correct the problem with includes.

Additional include directory You have to include additional library Directories as: c:\xxx\xxx\install\x64\vc16\lib x64 depends if you compiled opencv for 64 or 32 bits, vc16 is Visual Studio 2019.

Additional library directories

The Additional dependencies on the following picture provide opencv_MODULE420.lib, where module is core, video, videoio, etc. If you have a problem here, The message symbol is not resolved will occur. Additional dependencies

I recently did a tutorial for this here funvision blog HERE in case you have a problem with installation by CMAKE. The tutorial includes the installation of GSTREAMER as well.

globalex
  • 549
  • 3
  • 11
  • Thank you! I was not able to make this work and was searching for hours on the net to find a clue, and everything was about python; no-one thinks about the poor c++ devs nowadays :/ With your tutorial it works perfect. – mcy Nov 30 '20 at 13:43