我是一个完整的c ++和opencv初学者,我想学习它。我正在使用visual 2008.as一堂课,我试图显示一个.jpg图片,但该程序不会编译。调试时,我收到此错误:
1> main.cpp 1> c:\ users \ ralf \ documents \ visual studio 2008 \ projects \ 3)\ 3)\ main.cpp(1):致命错误C1083:无法打开 包含文件:'cv.h':没有这样的文件或目录
1>保存了构建日志 在“file:// c:\ Users \ ralf \ Documents \ Visual Studio 2008 \ Projects \ 3)\ 3)\ Debug \ BuildLog.htm“1> 3) - 1个错误,0 警告(S)
==========构建:0成功,1失败,0最新,0跳过==========
我想这是关于链接器和我必须包含哪些文件,以及如何.... ^^ 我在项目下编写了以下内容 - > properties-> Linker-> Input->附加依赖项(窗口左下角的Active(Debug)):
opencv_highgui230d.lib
opencv_core230d.lib
opencv_cv.lib
发布中的写道:
opencv_highgui230.lib
opencv_core230.lib
最后但并非最不重要,这是我的代码
#include <cv.h>
#include <highgui.h>
int main(int argc, char* argv[])
{
IplImage* img = cvLoadImage( "IMG_7321_.jpg" );
cvNamedWindow( "MyJPG", CV_WINDOW_AUTOSIZE );
cvShowImage("MyJPG", img);
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "MyJPG" );
return 0;
}
答案 0 :(得分:0)
Linux的:
g++ -o _test test.cpp -lcv -lhighgui
视窗:
@"C:\Program Files\CodeBlocks\MinGW\bin\g++.exe" -O3 -Wall -Iinclude \
-o test.exe test.cpp \
libopencv_core230.dll libopencv_highgui230.dll libopencv_imgproc230.dll
源代码,test.cpp:
#include <opencv/cv.h>
#include <opencv/highgui.h>
int main (int argc, char **argv) {
if (argc < 2) return -1;
char *filename_i = argv[1];
IplImage* img = cvLoadImage(filename_i, CV_LOAD_IMAGE_COLOR);
cvShowImage("Test Window", img);
cvWaitKey(5*1000);
return 0;
}
需要的DLL:
$ ls -1 *.dll
libgcc_s_dw2-1.dll
libopencv_calib3d230.dll
libopencv_contrib230.dll
libopencv_core230.dll
libopencv_features2d230.dll
libopencv_flann230.dll
libopencv_gpu230.dll
libopencv_highgui230.dll
libopencv_imgproc230.dll
libopencv_legacy230.dll
libopencv_ml230.dll
libopencv_objdetect230.dll
libopencv_video230.dll
libstdc++-6.dll
您可以从网址获取我的资讯包:http://pacify.ru/download/opencv-showimage-test.tgz