USING OPENCV 2.4.2 WITH VISUAL STUDIO 2012 ON WINDOWS 7 (64-BIT)
2013-01-24 22:22
691 查看
转自 http://karanjthakkar.wordpress.com/2012/11/21/usin-opencv-2-4-2-with-visual-studio-2012-on-windows-7-64-bit/
作者KARAN THAKKAR
So before starting you’ll need to make sure you have these in your computer:
Visual Studio 2012 (You can download the 90-day trial version from here)
OpenCV 2.4.2 (You can download it from here)
Extract OpenCV in a folder named OpenCV-2.4.2 in C drive.
[Note: You can change the path and folder name but then you wont be able to use the instructions as they are and you'll have to make modifications]
There are five simple steps that we have to make sure that we follow to get OpenCV up and running smoothly: (Click on the images to enlarge them)
Add the path to OpenCV runtime dll’s (Dynamic Linked Libraries) to your Environment Path variable:
[For 64-bit Machines] C:\OpenCV-2.4.2\opencv\build\x64\vc10\bin;C:\OpenCV-2.4.2\opencv\build\common\tbb\intel64\vc10;
[For 32-bit Machines] C:\OpenCV-2.4.2\opencv\build\x86\vc10\bin;C:\OpenCV-2.4.2\opencv\build\common\tbb\ia32\vc10;
The first path[
is for OpenCV runtime dll’s and the second path[
adds Intel Threaded Building Blocks to
enable parallel code in OpenCV. Adding Intel TBB dll’s is OPTIONAL. Without it you won’t be able to use multiple cores unless you multithreaded
your own application.
Create a new Visual Studio Project. Open Visual Studio -> New Project -> Visual C++ -> Win32 Console Application. Click OK. Then
click Next -> Finish.
[This step is for people with 64-bit machines. People with 32-bit machines can skip it.] Now change the build configuration by going to Build menu
-> Configuration Manager.
Change the Platform. Click on Win32, Select New. Use
the settings as shown in the figure.
Step 3
Click OK. Close the Configuration
Manager. Change the configuration in the main window to Release, if it isnt that already.
Now we add the OpenCV libraries to our OpenCV project properties. Go to View -> Other Windows -> Property Manager. Then open
the Release | x64 (32-bit users should open Release
| Win32) Property page by double clicking on it:
Go to Linker -> General -> Additional Library Directories. Add this path over there:
[For 64-bit Machines] C:\OpenCV-2.4.2\opencv\build\x64\vc10\lib;
[For 32-bit Machines] C:\OpenCV-2.4.2\opencv\build\x86\vc10\lib;
Next, go to Linker -> Input -> Additional Dependencies.
Add the following dependencies to it:
opencv_core242.lib
opencv_imgproc242.lib
opencv_highgui242.lib
opencv_ml242.lib
opencv_video242.lib
opencv_features2d242.lib
opencv_calib3d242.lib
opencv_objdetect242.lib
opencv_contrib242.lib
opencv_legacy242.lib
opencv_flann242.lib
Now we add the OpenCV include directories to our OpenCV project properties. In the same Property page, go to C/C++ -> General ->
Additional Include Directories and add the following path:
[For both 32-bit and 64-bit Machines] C:\OpenCV-2.4.2\opencv\build\include\opencv;C:\OpenCV-2.4.2\opencv\build\include;
[Optional: Go to C/C++ -> Preprocessor -> Preprocessor Definitions and add this:_CRT_SECURE_NO_WARNINGS; Helps
avoid unnecessary warnings sometimes]
OKAY! So now we are done with the adjustments. Go ahead and try this simple code which displays the video stream from your webcam.
Once you get this basic sample up and running, you can try out other Visual Studio projects like face-detection and face-extraction I’ve
put up on github.
Post your feedback or any problems that you encounter in comments.
Some blog posts that helped me figure stuff out:
1. http://jepsonsblog.blogspot.in/2012/07/installation-guide-opencv-24-with.html
2. http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-studio-2010-in-windows-7-64-bit/
作者KARAN THAKKAR
So before starting you’ll need to make sure you have these in your computer:
Visual Studio 2012 (You can download the 90-day trial version from here)
OpenCV 2.4.2 (You can download it from here)
Extract OpenCV in a folder named OpenCV-2.4.2 in C drive.
[Note: You can change the path and folder name but then you wont be able to use the instructions as they are and you'll have to make modifications]
There are five simple steps that we have to make sure that we follow to get OpenCV up and running smoothly: (Click on the images to enlarge them)
STEP-1
Add the path to OpenCV runtime dll’s (Dynamic Linked Libraries) to your Environment Path variable:[For 64-bit Machines] C:\OpenCV-2.4.2\opencv\build\x64\vc10\bin;C:\OpenCV-2.4.2\opencv\build\common\tbb\intel64\vc10;
[For 32-bit Machines] C:\OpenCV-2.4.2\opencv\build\x86\vc10\bin;C:\OpenCV-2.4.2\opencv\build\common\tbb\ia32\vc10;
The first path[
C:\OpenCV-2.4.2\opencv\build\x64\vc10\bin]
is for OpenCV runtime dll’s and the second path[
C:\OpenCV-2.4.2\opencv\build\common\tbb\intel64\vc10]
adds Intel Threaded Building Blocks to
enable parallel code in OpenCV. Adding Intel TBB dll’s is OPTIONAL. Without it you won’t be able to use multiple cores unless you multithreaded
your own application.
STEP-2
Create a new Visual Studio Project. Open Visual Studio -> New Project -> Visual C++ -> Win32 Console Application. Click OK. Thenclick Next -> Finish.
STEP-3
[This step is for people with 64-bit machines. People with 32-bit machines can skip it.] Now change the build configuration by going to Build menu-> Configuration Manager.
Change the Platform. Click on Win32, Select New. Use
the settings as shown in the figure.
Step 3
Click OK. Close the Configuration
Manager. Change the configuration in the main window to Release, if it isnt that already.
STEP-4
Now we add the OpenCV libraries to our OpenCV project properties. Go to View -> Other Windows -> Property Manager. Then openthe Release | x64 (32-bit users should open Release
| Win32) Property page by double clicking on it:
Go to Linker -> General -> Additional Library Directories. Add this path over there:
[For 64-bit Machines] C:\OpenCV-2.4.2\opencv\build\x64\vc10\lib;
[For 32-bit Machines] C:\OpenCV-2.4.2\opencv\build\x86\vc10\lib;
Next, go to Linker -> Input -> Additional Dependencies.
Add the following dependencies to it:
opencv_core242.lib
opencv_imgproc242.lib
opencv_highgui242.lib
opencv_ml242.lib
opencv_video242.lib
opencv_features2d242.lib
opencv_calib3d242.lib
opencv_objdetect242.lib
opencv_contrib242.lib
opencv_legacy242.lib
opencv_flann242.lib
STEP-5
Now we add the OpenCV include directories to our OpenCV project properties. In the same Property page, go to C/C++ -> General ->Additional Include Directories and add the following path:
[For both 32-bit and 64-bit Machines] C:\OpenCV-2.4.2\opencv\build\include\opencv;C:\OpenCV-2.4.2\opencv\build\include;
[Optional: Go to C/C++ -> Preprocessor -> Preprocessor Definitions and add this:_CRT_SECURE_NO_WARNINGS; Helps
avoid unnecessary warnings sometimes]
OKAY! So now we are done with the adjustments. Go ahead and try this simple code which displays the video stream from your webcam.
01 | #include "stdafx.h" |
02 | #include "opencv2/highgui/highgui.hpp" |
03 |
04 | /** |
05 | * @function main |
06 | */ |
07 | int main( int argc, const char ** argv ) |
08 | { |
09 | CvCapture* capture; |
10 | IplImage* frame = 0; |
11 |
12 | while ( true ) |
13 | { |
14 | //Read the video stream |
15 | capture = cvCaptureFromCAM(1); |
16 | frame = cvQueryFrame( capture ); |
17 |
18 | // create a window to display detected faces |
19 | cvNamedWindow( "Sample Program" , CV_WINDOW_AUTOSIZE); |
20 |
21 | // display face detections |
22 | cvShowImage( "Sample Program" , frame); |
23 |
24 | int c = cvWaitKey(10); |
25 | if ( ( char )c == 27 ) { exit (0); } |
26 |
27 | } |
28 |
29 | // clean up and release resources |
30 | cvReleaseImage(&frame); |
31 |
32 | return 0; |
33 |
34 | } |
put up on github.
Post your feedback or any problems that you encounter in comments.
Some blog posts that helped me figure stuff out:
1. http://jepsonsblog.blogspot.in/2012/07/installation-guide-opencv-24-with.html
2. http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-studio-2010-in-windows-7-64-bit/
相关文章推荐
- How to compile a C/C++ DLL for 64 bit with Visual Studio?
- 64-bit Managed Custom Actions with Visual Studio
- .NET Memory Allocation Profiling with Visual Studio 2012
- How to configure and use Git with visual studio 2012 and TFS
- How to debug c++ console application with argument in visual studio 2012
- Create custom Task List and Forms in SharePoint 2010 with Visual Studio 2012
- Debugging 64-bit applications using Visual Studio 2005
- Develop Arduino Using Visual Studio 2012 on Windows 8
- Install ArcGIS Developer Kit 10 with Visual Studio 2012
- Windows XP Targeting with C++ in Visual Studio 2012
- .NET Memory Allocation Profiling with Visual Studio 2012
- Deploying COM Add-ins for 64-bit Office using Visual Studio (Saaid Khan for Nathan Halstead)
- Using color themes with Visual Studio 2012 Express Editions
- [转载]Getting Started with ASP.NET vNext and Visual Studio 14
- Native Client - Development Cycle - Debugging with Visual Studio
- Visual Studio Ultimate 2012 静态激活密钥
- Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
- Microsoft Visual Studio 2012 (VS2012) 更改编码格式 "UTF-8"
- SQL Schema Comparison with Visual Studio 2010
- Load testing with Visual Studio Ultimate