You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Here is a simple step-by-step tutorial to installation and configuration of Open CV with C++ and Visual Studio 15.
This installation guide is bas(ically identical to)ed on this guide found online: https://www.deciphertechnic.com/install-opencv-with-visual-studio/


1) Install Visual Studio 15


 From this page. Download the excution file and run it. The installer is self-explaining, just keep the express settings, pressing "next" all the time.


2) Install OpenCV


From this page. I recommend you to install the latest stable version (Open CV - 4.1.1  04.10.2019) . Press the big button saying "Windows" to download the executable file. Run the file. I highly recommend you to extract the Open CV package in your root directory (C:/).


3) Add Open CV to system PATH


Press the Windows-button (⊞) on your keybord, type "Advanced System Settings" and go to these settings. Further navigate to Environment Variables > System Variables > Path

Click Edit, and then click New to add a new environment variable. Here, paste in the path if the bin folder inside your Open CV package. If you extracted the package in your root directory the path should be something like: C:\opencv\build\x64\vc14\bin

Press OK and then OK again to exit the environment variable dialog.


4) Get started with a project in Visual Studio and test the Open CV installation


Open up Visual Studio ( ⊞Win → start typing "Visual Studio" → press enter).

Create a new project as a Win32 Console application using Visual C++. Choose Empty Project and press Finish.

Press Ctrl + Shift + A and add a new Source file to your project and name it "main". This will open up your new cpp-file in the editor.

Right click on your project in the Solution Explorer and press Open Folder in File Explorer. Add a new folder and name it "data". Then save the picture below as a jpg-file and name it "lena".

Image result for lena image


Now, paste the following code to your main.cpp-file in your Visual Studio project:


#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
  Mat img = imread("data/lena.jpg");
  namedWindow("image", WINDOW_NORMAL);
  imshow("image", img);
  waitKey(0);
  return 0;
}


#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
  Mat img = imread("lena.jpg");
  namedWindow("image", WINDOW_NORMAL);
  imshow("image", img);
  waitKey(0);
  return 0;
}









  

  • No labels