VC Express under the installation of OpenCV2.3.1
Attention:
- The following documents take VC2008 Express as an example, the configuration under VC2010 should be similar to this document.
- VC 6.0 is not supported by OpenCV 2.3.1.
- VC Express is a free version provided by Microsoft and can be downloaded from here: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express
- It is recommended that you do not compile yourself, and if you have problems with pre-compiled libraries, try compiling them yourself.
Directory [hide]
- 1 installation required software
- 1.1 download OpenCV
- 1.2 < Span class= "Toctext" > install CMake (do not plan to compile yourself without installing)
- 2 compile OpenCV (not required step)
- 2.1 export VC + + project file with CMake
- 2.2 < Span class= "Toctext" > compile OpenCV Debug and release repositories
- 3 Configuring the VC
- 3.1 Configuring include Paths
- 3.2 Configuring the Lib path
- 4 Setting environment variables
- 5 Programming with OpenCV 2.3.1
- 6 author
|
[edit] software required for installation [edit] Download OpenCV
- Download the column http://www.opencv.org.cn/index.php/Download download OpenCV for Windows (also known as Opencv-2.3.1-win-superpack.exe files).
- Unzip the Opencv-2.3.1-win-superpack.exe and place it in a directory, for example
D:\Program Files\OpenCV2.3.1 (without running Setup.exe, unzip it). The directory structure after decompression is as follows.
-
Click to view larger image
[Edit] Install CMake (do not plan to build yourself without installing)
Download Windows (Win32 Installer) installation from http://www.cmake.org/cmake/resources/software.html.
[Edit] Compile OpenCV (non-required steps) [Edit] Export VC + + project file with CMake
- Run Cmake-gui, set the where is the source code path to the OPENCV installation path (This document assumes the installation location is:
D:\Program Files\OpenCV2.3.1\opencv ), and create subdirectories D:\Program Files\OpenCV2.3.1\opencv\build\my , and will CMake "where to build the binaries "is set to this directory.
- Then click Configure, and in the popup dialog box, select Visual Studio 9 2008.
- You can modify the options according to your system, modify and then select "Congfigure", after completion, select "Generate".
(Note: The directory where the open CV file is placed cannot contain Chinese characters, otherwise "congfigure" and "Generate" cannot succeed, and you need to close the already open VS, otherwise cmake and VS macros cannot be configured.) By:jackyzzy Zhaozhenyang)
| 2.0 version is for reference only, click to see larger image |
Click to view larger image |
2.0 version is for reference only, click to see larger image |
[Edit] Compile OpenCV Debug and release repositories
After completing the previous step, the OpenCV.sln VC solution File will be generated under the D:\Program files\opencv2.3.1\opencv\build\my directory, please use VC + + 2008 Express Open OpenCV.sln and do the following:
- Under Debug, select Solution OpenCV (solution "OpenCV") in the Solution Explorer (Solution Explorer), right-click, run "Rebuild solution", or compile without errors, Then select the Install Project and run "Build".
- Under Release, select the solution OpenCV in the Solution Explorer, right-click, run "Rebuild solution", such as compile error-free, then select Install Project, run "Build".
When all is done, the OPENCV library for your system is generated.
[edit] config vc[edit] Configure include path
Also tell VC where to go to find OpenCV head file, open VC, select Menu Tools, Options, projects and solutions, "VC + + Directory", "Include files", including D:\Program Files\OpenCV2.3.1\opencv\build\include;D:\Program Files\OpenCV2.3.1\opencv\build\include\opencv;D:\Program Files\OpenCV2.3.1\opencv\build\include\opencv2 If you compiled it yourself, enter D:\Program files\opencv2.3.1\opencv\build\my\install\include
-
Click to view larger image
[Edit] Configure the Lib path
That is, tell VC where to go to find OpenCV library files.
In the file opencv-2.3.1-win-superpack.exe just downloaded, the dynamic library and the static library have been pre-compiled for VC2008 and VC2010. So we don't need to compile opencv ourselves with CMake as in previous versions.
- Your own compiled library, the Library directory is:
D:\Program Files\OpenCV2.3.1\opencv\build\my\install\lib
(Note: Because of the successful compilation, lib file in debug and release two files, load the library to debug and release, I configured the library directory is: D:\Program files\opencv2.3.1\opencv\ Build\my\install\lib\debug, otherwise the open CV code cannot be entered during debugging. By:jackyzzy Zhaozhenyang)
- 32-bit Systems & VC2008, library directory:
D:\Program Files\OpenCV2.3.1\opencv\build\x86\vc9\lib
- 32-bit Systems & VC2010, library directory:
D:\Program Files\OpenCV2.3.1\opencv\build\x86\vc10\lib
- 64-bit Systems & VC2008, library directory:
D:\Program Files\OpenCV2.3.1\opencv\build\x64\vc9\lib
- 64-bit Systems & VC2010, library directory:
D:\Program Files\OpenCV2.3.1\opencv\build\x64\vc10\lib
Please select one according to your own situation four. Enter the library directory into the VC + + directory, projects and solutions, tools, options, and so on. As shown in the following:
| Click to view larger image |
Click to view larger image |
Click to view larger image |
[Edit] Set environment variables
Just set up a dynamic library, so you also need to add the directory where the OpenCV DLL file is located in the PATH environment variable. DLL file directory as follows, please choose one according to your own situation:
- The library that compiles itself, the DLL directory is:
D:\Program Files\OpenCV2.3.1\opencv\build\my\install\bin
- The 32-bit system & Vc2008,dll directory is:
D:\Program Files\OpenCV2.3.1\opencv\build\x86\vc9\bin
(Note: Here the environment variables should be consistent with the top library directory, so that debugging can enter the code, my own directory is: D:\Program files\opencv2.3.1\opencv\build\x86\vc9\bin\debug. By:jackyzzy Zhaozhenyang)
- The 32-bit system & Vc2010,dll directory is:
D:\Program Files\OpenCV2.3.1\opencv\build\x86\vc10\bin
- The 64-bit system & Vc2008,dll directory is:
D:\Program Files\OpenCV2.3.1\opencv\build\x64\vc9\bin
- The 64-bit system & Vc2010,dll directory is:
D:\Program Files\OpenCV2.3.1\opencv\build\x64\vc10\bin
Because some functions require TBB, it is necessary to add the directory where TBB resides in the environment variable path. TBB-related DLL paths are:
- 32-bit Systems & VC2008:
D:\Program Files\OpenCV2.3.1\opencv\build\common\tbb\ia32\vc9
- 32-bit Systems & VC2010:
D:\Program Files\OpenCV2.3.1\opencv\build\common\tbb\ia32\vc10
- 64-bit Systems & VC2008:
D:\Program Files\OpenCV2.3.1\opencv\build\common\tbb\intel64\vc9
- 64-bit Systems & VC2010:
D:\Program Files\OpenCV2.3.1\opencv\build\common\tbb\intel64\vc10
As shown in the directory system environment variable path where the DLL files for OpenCV and TBB are located. You may need to log out of the current Windows user (or restart) after you join to take effect.
| Click to view larger image |
Click to view larger image |
[Edit] Programming with OpenCV 2.3.1
- Open VC + + Express, create a Win32 console program Helloopencv;
-
Click to view larger image
- Select the Opencvhello project in the Solution Explorer and click the right mouse button to select Properties.
-
Click to view larger image
- opencv_calib3d231d.lib; opencv_contrib231d.lib; opencv_ Core231d.lib; Opencv_features2d231d.lib; Opencv_flann231d.lib; Opencv_gpu231d.lib; Opencv_highgui231d.lib; Opencv_imgproc231d.lib; Opencv_legacy231d.lib; Opencv_ml231d.lib; Opencv_objdetect231d.lib; Opencv_ts231d.lib; Opencv_video231d.lib (can be cut according to actual needs) note, please open a new editing window (that is, click the "..." button) " Additional Dependencies ", and one by one add, one line (a carriage return), (note that the end of the line does not add"; ") Otherwise, you may receive an error similar to the following: 1>LINK&NBSP;: Fatal error LNK1104: Cannot open file "... lib"
-
-
Click to view larger image
- Add [Additional Dependencies Additional Dependencies] for the release configuration of the project:
opencv_calib3d231.lib; opencv_contrib231.lib; opencv_core231.lib; opencv_features2d231.lib; opencv_flann231.lib; opencv_gpu231.lib; opencv_highgui231.lib; opencv_imgproc231.lib; opencv_legacy231.lib; opencv_ml231.lib; opencv_objdetect231.lib; opencv_ts231.lib; opencv_video231.lib (can be truncated according to actual needs) *
-
Click to view larger image
- Compile and run the following routine (you will need to place the Lena.jpg file in the project directory, which is the same location as the generated. exe file) (this is incorrect.) Double-click the EXE, the picture is placed in the same folder of the. exe, press F5 to run the program directly, Lena.jpg to put in HELLOOPENCV\HELLOOPENCV).
/*********************************************************************** * OpenCV 2.3.1 Test routines * Ushchi provides **************** *******************************************************/#include "stdafx.h"#include <opencv2/opencv.hpp> using namespace std; using namespace CV;int main(int ARGC,Char* argv[]){ConstChar* ImageName="Lena.jpg";Read the image from the file Mat img= Imread(imagename);If the read-in image failsIf(IMG.Empty()){fprintf(stderr,"Can Not load image%s\n ", imagename ) ; return -1;} //Display image Imshow ( "image" , Img) ; // This function waits for the key and presses any key on the keyboard to return Waitkey (; return 0; } /span>
-
program run result diagram, click to see larger image
VC Express under the installation of OpenCV2.3.1