设为首页 收藏本站
查看: 646|回复: 0

[经验分享] USING OPENCV 2.4.2 WITH VISUAL STUDIO 2012 ON WINDOWS 7 (64-BIT)

[复制链接]
累计签到:5 天
连续签到:1 天
发表于 2015-11-4 11:03:33 | 显示全部楼层 |阅读模式
  转自 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)
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 toenable parallel code in OpenCV. Adding Intel TBB dll’s is OPTIONAL. Without it you won’t be able to use multiple cores unless you multithreadedyour 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. Usethe settings as shown in the figure.
http://karanjthakkar.files.wordpress.com/2012/11/step-3-ii.jpg?w=698
[size=1.4]Step 3

Click OK. Close the ConfigurationManager. Change the configuration in the main window to Release, if it isnt that already.
http://karanjthakkar.files.wordpress.com/2012/11/step-31.jpg?w=698
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:
http://karanjthakkar.files.wordpress.com/2012/11/step-41.jpg?w=300&h=160
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.
http://karanjthakkar.files.wordpress.com/2012/11/step-4i.jpg?w=300&h=213
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; Helpsavoid 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 main06*/07int main( int argc, const char**argv )08{09CvCapture*capture;10IplImage*frame = 0;11 12while (true)13{14//Readthe video stream15capture= cvCaptureFromCAM(1);16frame= cvQueryFrame( capture );17 18//create a window to display detected faces19cvNamedWindow("SampleProgram",CV_WINDOW_AUTOSIZE);20 21//display face detections22cvShowImage("SampleProgram",frame);23 24int c= cvWaitKey(10);25if((char)c== 27 ) { exit(0);}26 27}28 29//clean up and release resources30cvReleaseImage(&frame);31 32return 0;33 34}
Once you get this basic sample up and running, you can try out other Visual Studio projects like face-detection and face-extraction I’veput 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/

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-134894-1-1.html 上篇帖子: Windows Server 2012 安装笔记 下篇帖子: Windows Server 2012正式版RDS系列⑻
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表