OpenCV (open source computer Vision Library) is an open source, cross-platform open source computer Vision library that runs on Windows, Linux, Mac and other platforms, written in C and C + +, lightweight and efficient.
Here's how to install OpenCV on a Win7 64-bit system and how to use VS2013 for OPENCV-based program development. OPENCV Library is encapsulated in Lib and DLL, and there are two versions, one is x86 (32-bit), one is x64 (64-bit), I use 32-bit library on 64-bit system is not successful, so this tutorial is only applicable to Win7 64-bit system, the development environment uses the visual Stdio 2013.
First step: Download OpenCV and install
: http://opencv.org/downloads.html
When the download is complete, click Run. Here is the installation, you need to set the installation path:
To configure environment variables:
Right-click on the desktop computer, select Properties, advanced system settings, environment variables,
Create a new OPENCV variable in the system variable, as follows:
Then select the path variable in the system variable, use%opencv%, and introduce the variable into
Step two: Create an empty project in VS2013
Step Three: Configure item properties 1. Right-click the project name, select Properties, go to property page, 2. Configure executable directory, include directory, reference directory
Configuration process: Click on the corresponding input box, select Edit, then add, then select the corresponding directory, the following is the edit page:
The folder style icon is the new directory;
The following directories should be added to the three input boxes:
E:\OpenCV\ is the installation path
Executable directory (executable directories): |
E:\OpenCV\opencv\build\x64\vc12\bin |
Include directory (Include Directories): |
E:\opencv\opencv\build\includee:\opencv\opencv\build\include\opencve:\opencv\opencv\build\include\opencv2 |
Reference directory (Reference directories): |
E:\OpenCV\opencv\build\x64\vc12\lib |
3. Enter the linker (Linker) to add a dependent library
For example, enter linker->input->additional dependencies to add additional dependent libraries:
Click Edit, and then add the E:\OpenCV\opencv\build\x64\vc12\lib library file to the LIB, If the reader version and I agree (2.4.8), you can directly copy and paste the following code into the Edit input box (I was added to the ... If you are configuring a 32-bit system, simply replace the x64 with the x86, so you don't have to lose each one. ):
E:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_calib3d248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_calib3d248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_contrib248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_contrib248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_core248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_core248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_features2d248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_flann248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_flann248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_gpu248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_gpu248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_features2d248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_highgui248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_highgui248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_imgproc248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_imgproc248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_legacy248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_legacy248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_ml248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_ml248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_nonfree248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_nonfree248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_objdetect248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_objdetect248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_ocl248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_ocl248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_photo248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_photo248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_stitching248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_stitching248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_superres248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_superres248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_ts248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_ts248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_video248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_video248d.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_videostab248.libe:\OPENCV\OPENCV\build\x64\VC12\lib\OPENCV_videostab248d.lib
4. Modify target machine to 64 bits
Enter Linker->advanced->target machine, change the value to MachineX64
5. Modify the project build property to 64 bits
Select Builder->configuration Manager, then click the Win32 drop-down box,
Select New, Pop Up the dialog box below and select x64 in the Arm box.
6. Add C + + files for testing
Create a new C + + file in the project
Enter the following code (copy from "Learning OpenCV Chinese Version"):
#include "highgui.h"int main(intchar** argv){ IplImage* img = cvLoadImage(argv[1]); cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE); cvShowImage("Example1", img); cvWaitKey(0); cvReleaseImage(&img); cvDestroyWindow("Example1");}
If the runtime is just a black box, press Enter also reported wrong (but press ENTER before the error is not OK).
Then go to the project directory:
$ (project directory) \x64\debug
Put a picture in it (mine is fruits.jpg)
Open a CMD window, enter the name of the program we generated (that is, the project name) and the name of the image, you can run this program--open a picture.
Picture effect:
Installation of OpenCV on the "OpenCV base" Win7 64-bit system and configuration on VS2013