1. Install

Download OpenCV from:
Lastest
Homepage

Click the file you downloaded, choose a location to extract it.

2. Configuration

2.1 Environment

Configure your environment variables, for example, I add ;D:\Program Files\OpenCV\build\x86\vc12\bin to path:
environment path

2.2 Project

Then open VS2013, and find project/properties:
vs properties 1

In VC++ Directories/Include Directories, add:

D:\Program Files\opencv\build\include
D:\Program Files\opencv\build\include\opencv
D:\Program Files\opencv\build\include\opencv2

In VC++ Dorectories/Library Directories, add:
D:\Program Files\opencv\build\x86\vc12\lib

vs properties 2

Then in Linker/Input/Additional Dependencies, add:

opencv_ml249d.lib
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_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib

3. Comment

If we use opencv-2.4.10, just change 249 to 2410, opencv-2.4.8 to 248. And there are equivalent .lib file without ‘d’, e.g.: opencv_videostab249.lib, it is used when we need to realease a project but not debug.
And it is much easier in opencv-3.0, only a opencv_ts300d.lib or a opencv_ts300.lib will work.