Note: most of the part is copied from [2], I tried [2] and [1] ,but failed due to some errors. Then I made some changes and it worked.
The following is what I did.
Step 1:Download and Installing
suppose you already have VS on your PC
Download the opencv-master zip from: https://github.com/Itseez/opencv
Download opencv_contrib zip from: https://github.com/itseez/opencv_contrib
Download Cmake from: https://cmake.org/download/
(Youcan download the latest version of cmake if you’re using recent versions of VS)
Extract the opencv-master zip and rename the folder as opencv
Extract opencv_contrib.
Step 2: Building and compiling
Create a new folder build inside the opencv folder.
Launch CMake application and then specify the source as 'opencv' folder and build as 'build' folder inside opencv folder.
Click on configure. It’ll open a new window to select the compiler. If you’re using VS 2013 choose ‘Visual Studio12 2013 win64’.
Click finish.
Wait until configuring is done.
Select what you want in the window and check or uncheck the box. Make sure to check ENABLE_SOLUTION_FOLDERS.If you want to install extra modules, find OPENCV_EXTRA_MODULES_PATH and browse folder. D:/opencv3/opencv_contrib/modules for example.
Click configure again.
After this time configuring is done, click confiigure once again.
This time when it is done, the red background should disappear. If it is the case, click generate.
This will create an 'OpenCV.sln' file inyour build folder. Open it with Visual Studio.
In the solution explorer, right clickon ALL_BUILD and build. This will take time. Once it's built,change the build mode to RELEASE and repeat the same step
After that, right click on INSTALL and build it, Once it's built, again change the build mode to DEBUGand repeat the same step.
Everything will be created in the'install' folder.
Step 3: Creating asystem variable:
Variable name: OPENCV_DIR
Value: D:\opencv3\opencv\build
Path: %OPENCV_DIR%\install\x64\vc12\bin
Step 4:Configuration to test a sample project
Open Visual Studioand create a Console Application
Right click on the file and clickproperties
Choose Configuration Manager and add x64platform if your system is x64 (only if your system is x64)
At configuration field, choose allconfigurations
At ConfigurationProperties -> C/C++ -> Additional IncludeDirectories, add opencv include folders
Additional IncludeDirectories:
D:\opencv3\opencv\build\install\include
D:\opencv3\opencv\build\install\include\opencv
D:\opencv3\opencv\build\install\include\opencv2
Note: opencv3 isthe folder in which I extracted the files (Check your folder name and folderlocation)
At ConfigurationProperties -> Linker -> Additional Library Directories,add opencv library folder
Additional LibraryDirectories:
D:\opencv3\opencv\build\install\x64\vc12\lib
At configuration field, choose Debug mode
At Configuration Properties -> Linker-> Additionaldependencies -> add dependence libraries
Additionallibraries
opencv_aruco300d.lib;opencv_bgsegm300d.lib;opencv_bioinspired300d.lib;opencv_calib3d300d.lib;opencv_ccalib300d.lib;opencv_core300d.lib;opencv_datasets300d.lib;opencv_dnn300d.lib;opencv_dpm300d.lib;opencv_face300d.lib;opencv_features2d300d.lib;opencv_flann300d.lib;opencv_hal300d.lib;opencv_highgui300d.lib;opencv_imgcodecs300d.lib;opencv_imgproc300d.lib;opencv_ml300d.lib;opencv_objdetect300d.lib;opencv_optflow300d.lib;opencv_photo300d.lib;opencv_reg300d.lib;opencv_rgbd300d.lib;opencv_saliency300d.lib;opencv_shape300d.lib;opencv_stereo300d.lib;opencv_stitching300d.lib;opencv_structured_light300d.lib;opencv_superres300d.lib;opencv_surface_matching300d.lib;opencv_text300d.lib;opencv_tracking300d.lib;opencv_ts300d.lib;opencv_video300d.lib;opencv_videoio300d.lib;opencv_videostab300d.lib;opencv_xfeatures2d300d.lib;opencv_ximgproc300d.lib;opencv_xobjdetect300d.lib;opencv_xphoto300d.lib;
Note: These libraries are in the folder- D:\opencv3\opencv\build\install\x64\vc12\lib
and if you've installed extra modules you'll have to include those librariesas well. This list contains the default libs and the extra 'opencv_face300d.lib'from the face module.
At configuration field, choose Release mode
At ConfigurationProperties -> Linker -> Additionaldependencies -> add dependence libraries
Additionallibraries
opencv_aruco300.lib;opencv_bgsegm300.lib;opencv_bioinspired300.lib;opencv_calib3d300.lib;opencv_ccalib300.lib;opencv_core300.lib;opencv_datasets300.lib;opencv_dnn300.lib;opencv_dpm300.lib;opencv_face300.lib;opencv_features2d300.lib;opencv_flann300.lib;opencv_hal300.lib;opencv_highgui300.lib;opencv_imgcodecs300.lib;opencv_imgproc300.lib;opencv_ml300.lib;opencv_objdetect300.lib;opencv_optflow300.lib;opencv_photo300.lib;opencv_reg300.lib;opencv_rgbd300.lib;opencv_saliency300.lib;opencv_shape300.lib;opencv_stereo300.lib;opencv_stitching300.lib;opencv_structured_light300.lib;opencv_superres300.lib;opencv_surface_matching300.lib;opencv_text300.lib;opencv_tracking300.lib;opencv_ts300.lib;opencv_video300.lib;opencv_videoio300.lib;opencv_videostab300.lib;opencv_xfeatures2d300.lib;opencv_ximgproc300.lib;opencv_xobjdetect300.lib;opencv_xphoto300.lib;
Note:These libraries are in the folder- D:\opencv3\opencv\build\install\x64\vc12\lib
Include extra libraries of the modules you've installed.
Note:This is based on the x64 platform, so changes should be made to the properties of your project.
for example, the library should be:
$(VC_LibraryPath_x64)
$(WindowsSDK_LibraryPath_x64)
the target machine should be:
MachineX64 (/MACHINE:X64)
Anyway, adapt everything to x64 mode.
Step 4: Build and Debug
Try this code for creating bounding circles and boxes for contours :http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.html
Copy -paste it, build it and Debug.
for more information, you can look at the references below.
References:
[1]https://putuyuwono.wordpress.com/2015/04/23/building-and-installing-opencv-3-0-on-windows-7-64-bit/
[2]http://audhootchavancv.blogspot.com/2015/08/how-to-install-opencv-30-and.html
[3]http://perso.uclouvain.be/allan.barrea/opencv/cmake_config.html
[4]http://docs.opencv.org/2.4/doc/tutorials/introduction/windows_install/windows_install.html