Who loves OpenCV, Windows & command line (Visual C++ 2015 Build Tools)? (raise my hand)
- Hope that everyone is using 64-bit version of Windows, since for 32-bit version of Windows, there is no official OpenCV version that just work.
If in doubt, go to Start Menu/Settings, select System, in left panel select About, at right panel shows your System type is 64-bit operating system, x64-based processor, then you are good.
- Download & install Visual C++ Build Tools 2015
- Download & extract OpenCV Win pack, say, to C:\opencv
- Save following example code with filename you like, and extension cpp. Say, showimage.cpp at C:\showimage
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
int main()
{
IplImage* img = cvLoadImage("orangeman.jpg");
cvShowImage("Original", img);
cvWaitKey(0);
cvReleaseImage(&img);
return 0;
}
- Copy these OpenCV files to where your code at, C:\showimage
C:\opencv\build\x64\vc15\lib\opencv_world340.lib
C:\opencv\build\x64\vc15\bin\opencv_world340.dll
C:\opencv\build\include\opencv2
- Go Start Menu/Visual C++ Build Tools, to use Visual C++ 2015 x64 Native Build Tools Command Prompt
- Navigate to your code at C:\showimage with the command.
cd C:\users\ME\showimage
- Build .exe file from your code and the OpenCV files, with the command.
cl showimage.cpp opencv_world340.lib
- You get showimage.exe, click and see.
No comments:
Post a Comment