如果Debug下不能运行,则切换到Release版本下!!!(以前网上查到,不明真相)
实践中可用的方案1:
http://blog.aguskurniawan.net/post/OpenCV-210-with-Visual-Studio-2010.aspx
OpenCV 2.1.0 with Visual Studio 2010
23. 六月 2010 00:24
OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision. Two months ago OpenCV released the new version of OpenCV 2.1. On this article, I would like to share how to use OpenCV with Visual Studio 2010.
System Requirements
- Download OpenCV 2.1 or the latest, [V]
- Download Visual Studio 2010, you can download an express edition [V]
I use Windows 7 x64 as development environment.
OpenCV 2.1 Installation
After you downloaded OpenCV library. Click setup file and then you’ll get a dialog as below
Click Next button
Click I Agree button
Choose Do not add OpenCV to the system PATH (you may choose any option) and then click Next button
Choose Destnation Folder that you want to store OpenCV files. After that, click Next button
Click Next button
Select the type of install Full. After that click Install button. Installer will install OpenCV library on your system.
Click Finish button to finish installation process.
Now you can see OpenCV 2.1 on your system. You can check on folder where OpenCV installed
Visual Studio 2010 Project Configuration
After you created a C/C++ project on Visual Studio 2010 you should configure OpenCV on Visual Studio 2010. Open properties dialog of project. Assume your OpenCV 2.1 installed on C:/OpenCV2.1
On properties dialog, click C/C++ –>General and entry C:/OpenCV2.1/include/opencv in Additional Include Directories
On properties dialog, click C/C++ –>Advanced and select Compile As. If you prefer C compiler, use Compile as C Code (/TC)
On properties dialog, click Linker –>General and entry C:/OpenCV2.1/lib in Additional Library Directories
On properties dialog, click Linker –>Input and entry all *.lib files in Additional Dependencies. If you’re running on debug mode, try to entry all *d.lib files
After you do all tasks above, click OK button on Propeties dialog.
Testing
For testing purpose, try to write this code (*note* change image file c:/temp/monas.jpg)
#include <stdio.h>#include <highgui.h>int main( int argc, char** argv ){IplImage* img = cvLoadImage( "c:/temp/monas.jpg",1 );cvNamedWindow("Monas", CV_WINDOW_AUTOSIZE );cvShowImage("Monas", img );cvWaitKey(0);cvReleaseImage( &img );cvDestroyWindow("Monas");}
Compile and run it. If success, you get image viewer dialog as below
when you run this code from Visual Studio and get error as below. Try to copy *.dll from OpenCV (C:/OpenCV2.1/bin) on folder where your executable file was located
