Steps to install OpenCV under VS2013

Before installing:
1、  vc8 = Visual Studio 2005,vc9 = Visual Studio 2008,vc10 = Visual Studio 2010,vc11 = Visual Studio 2012,vc12 = Visual Studio 2013。

2. The choice of x86 or x64 here is an often confusing question. Of course, for 32-bit operating systems, x86 is definitely the choice.
If it is a 64-bit operating system, many children's shoes will take it for granted and choose x64 wisely, but it is not. The correct understanding is this:
It doesn't matter if you have a 32-bit or 64-bit operating system, as long as you use the win32 compiler or the X64 compiler.
In fact, the configuration choice is not directly related to 64-bit or 32-bit system, but to which compiler you use when compiling your program.
The compiler chooses win32, and uses x86;
The compiler chooses X64, so use X64.
But in general, the x86 compiler of win32 is used. Therefore, regardless of the 32-bit or 64-bit operating system, the configuration file is best to choose the x86 version


3. I installed opencv on the E drive; VS didn't like to bother, so I installed the C drive directly


Installation process:



1. Install VS2013.
            
           Product Key: BWG7X-J98B3-W34RT-33B3R-JVYW9

2. Install OpenCV.


3. Set OpenCV environment variables
        1) Create the following options under the system environment variables
        
        2) Find the Path variable in the system variable and add the statement at the end - ;%OPENCV%\x86\vc12\bin           
        ( E:\opencv\build\x 86 \vc12 in opencv corresponds to vs2013 version ) ( vc10 means vs2010 )
        ( Select the x64 folder for 64-bit systems and the x86 folder for 32-bit systems )
              Or the above 2 steps, directly add the statement at the end of the Path variable—— ; E:\opencv\build\x86\vc12\bin  
        Note: After adding, you need to restart or log off the computer for the environment variable to take effect.

        3) Create new files opencvDebugConfiguration.props and opencvReleaseConfiguration.props in the root directory where OpenCV is                                          installed . These two files will be used in " 4.VS2013 Configuration " below.
            
            
        
4. VS2013 configuration
        1) Create an empty Win32 console application named OpencvTest.
        2) Select "View" - "Properties Manager" in the menu bar, then in the Properties Manager, right-click under the respective folders of the project - "Add Existing Properties" - find the above two .props file location and add it.
        3) Right-click opencvDebugConfiguration.props, select "Properties" - General Properties / "VC++ Directories" option,  
              Add E:\opencv\build\x86\vc12\lib under "Library Directory"
              Add E:\opencv\build\include in "include directory";
                                                E:\opencv\build\include\opencv; E:\opencv\build\include\opencv2 ; these three directories
                                                (This one can add or remove paths by having some icon buttons in the upper right corner).           
        4) Right-click opencvDebugConfiguration.props, select " Properties " - General Properties / "Linker" / "Input" option - click the "Additional Dependencies" fold on the right, then an "Edit" will appear. option, click "Edit", then a small box will pop up, we need to fill in some lib library files. The library files that need to be filled in are all under the "E:\opencv\build\x86\vc12\lib" folder, we only need to fill in the file name with the suffix of lib and the suffix into the box just now.
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib  
opencv_features2d249d.lib 
opencv_flann249d.lib 
opencv_gpu249d.lib 
opencv_highgui249d.lib 
opencv_imgproc249d.lib 
opencv_legacy249d.lib
opencv_ml249d.lib  
opencv_nonfree249d.lib  
opencv_objdetect249d.lib 
opencv_ocl249d.lib  
opencv_photo249d.lib  
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_ts249d.lib  
opencv_video249d.lib  
opencv_videostab249d.lib

      5)opencvReleaseConfiguration.props的配置同上4),只是将其中最后的d去掉,此为release版
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib
opencv_ml249.lib
opencv_nonfree249.lib
opencv_objdetect249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_videostab249.lib
(一共19个)
        6)有个配置最好弄一下,把E:\opencv\build\x86\vc12\bin下的所有东西copy到                                          C:\Windows\System32下面。。然后, 最好重启一下 ,让电脑了解一下咱们的配置啦,哈哈。


5.运行测试程序。
  右击源文件——“添加”——“新建项”——“C++ 文件 ”命名为test.cpp,并 将以下 测试代码复制到test.cpp中, 编译并运行程序,出现测试图片说明配置成功。

#include <opencv2/core/core.hpp>  
#include <opencv2/highgui/highgui.hpp>  
using namespace cv;

#include <iostream>
using namespace std;
int main()
{
Mat img =imread(" E://test.jpg ");// 读入一张图片,首先要在E盘中存入此图片
imshow("画", img);// 在窗口中显示
waitKey(30);// 等待30 ms后窗口自动关闭  
system("pause");
return 0;
}







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324770364&siteId=291194637