🥋0. OpenCV Build - option#1 easiest way

Contents

OpenCV Build Easiest way (1/2)
OpenCV Build Easiest way (2/2)


1. Preparation:

Download Visual studio IDE : https://visualstudio.microsoft.com/downloads/

Download OpenCV Library : https://opencv.org/releases.html

2. Window Environment Setting:

  • Window bin file path setting
  • Advanced system settings -> Environment Variables -> Edit System variables -> add opencv bin path

  • Add new path variable
  • Advanced system settings -> Environment Variables -> Add new opencv path in User variables for user

3. VS studio setting

  • select x64 mode

  • project -> properties

  • VC++ Directories -> Include Directories
  • Add $(OPENCV_LIB)include

  • VC++ Directories -> Library Directories
  • Add $(OPENCV_LIB)x64\cv15\lib

 

Code for testing

#include <iostream>
#include <opencv2/opencv.hpp>
#ifdef _DEBUG  
#pragma comment(lib, "opencv_world401d.lib")
#else
#pragma comment(lib, "opencv_world401.lib")
#endif 
using namespace cv;
using namespace std;
int main()
{
    VideoCapture stream1(0); //0 is the id of video device.0 if you have only one camera
    if (!stream1.isOpened()) { //check if video device has been initialised
        cout << "cannot open camera";
    }
    
    namedWindow("Processing");
    namedWindow("Origin");
    
    //unconditional loop
    while (true) {
        Mat cameraFrame;
        stream1.read(cameraFrame); //get one frame form video
        imshow("Origin", cameraFrame);
        Sobel(cameraFrame, cameraFrame, CV_8U, 1, 0); //sobel processing
        imshow("Processing", cameraFrame);

    if (waitKey(30) >= 0)
        break;
    }

    destroyAllWindows();
    return 0;
}

🙇🏻 Thank you!

 

🎁 Source code, Material(pdf) and example images : All Product -> OpenCV Lecture

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.