[batches from http://opencv-srf.blogspot.jp/]

DOWNLOAD:

  1. Visual Studio: https://www.visualstudio.com/ (I used VS Express 2013)
  2. OpenCV package: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/ (I used opencv 2.4.11)
  3. Unzip opencv directly into C:\. Example: C:/opencv2411/…

CONFIGURE PATHS

  1. My Computer > See operating system (x32/86 or x64)
  2. My Computer > System Settings (toolbar) > Advanced System Settings > Environment Variables > System variables
    • Select PATH and click Edit…
    • Add at the end the path for opencv:
      C:/opencv2411/build/x64/vc12/bin
    • vc10, vc11, vc12… are different versions of opencv. Make sure your version is compatible with Visual Studio. For instance, Visual Express 2013 is compatible with all three of them in this case.

CONFIGURE VISUAL STUDIO

First off, install Visual Studio. Then, create new C++ win32 console empty project.

Inside the Solution Explorer, where our project directory tree is, right click on the title of the project and go to Properties. If your system is x64, go to Configuration Manager… (top right). Inside this window, create a x64 active platform copied from/including win32. Sounds weird, just look around until you realize what I mean. Then set your project’s “Platform” to x64 and move on.

Inside Configuration Properties > C/C++ > General > Additional Include Directories: edit there and include this:

C:\opencv2411\build\include
C:\opencv2411\build\include\opencv
C:\opencv2411\build\include\opencv2

Inside Configuration Properties > Linker > General > Additional Library Directories: edit there and add the following:

C:\opencv2411\build\x64\vc12\lib

Inside Linker > Input > Additional Dependencies, you must add all .lib files contained inside C:\opencv2411\build\x64\vc12\lib. The ones ending in …d.lib refer to the Debug mode, while the others refer to the Release mode. Make sure to at least include the Debug mode ones, if not all of them. In the case of opencv2.4.11 these files are:

DEBUG:

opencv_calib3d2411d.lib
opencv_contrib2411d.lib
opencv_core2411d.lib
opencv_features2d2411d.lib
opencv_flann2411d.lib
opencv_gpu2411d.lib
opencv_highgui2411d.lib
opencv_imgproc2411d.lib
opencv_legacy2411d.lib
opencv_ml2411d.lib
opencv_nonfree2411d.lib
opencv_objdetect2411d.lib
opencv_ocl2411d.lib
opencv_photo2411d.lib
opencv_stitching2411d.lib
opencv_superres2411d.lib
opencv_ts2411d.lib
opencv_video2411d.lib
opencv_videostab2411d.lib

RELEASE:

opencv_stitching2410.lib
opencv_contrib2410.lib
opencv_videostab2410.lib
opencv_superres2410.lib
opencv_nonfree2410.lib
opencv_gpu2410.lib
opencv_ocl2410.lib
opencv_legacy2410.lib
opencv_ts2410.lib
opencv_calib3d2410.lib
opencv_features2d2410.lib
opencv_objdetect2410.lib
opencv_highgui2410.lib
opencv_video2410.lib
opencv_photo2410.lib
opencv_imgproc2410.lib
opencv_flann2410.lib
opencv_ml2410.lib
opencv_core2410.lib

That’s it! You are all set. You can try implementing some quick opencv functions like this one to see if everything works OK.

*Note: tutorials include a new variable called OPENCV_DIR or OPENCV_BUILD in system variables, and then use it everytime they have to call a path. While this helps in case of moving the main folder (you only need to modify one line, this variable, and everything else is automatically updated), this has been the cause of errors every time I tried installing it; so I recommend against.