![](/img/trans.png)
[英]Problem with running c++ opencv program in linux: functions not declared
[英]Problem in running exercice 2-4 from Learning Opencv, O'Reilly
我正在学习Bradsky和Kaehler的书《学习oPENCV,o'Reilly》。 我在Ubuntu 10.10上,以前的示例工作正常,但在2-4中我有问题。
这是代码:
#include "cv.h"
#include "highgui.h"
void example2_4( IplImage* image )
{
// Create some windows to show the input
// and output images in.
//
cvNamedWindow( "Example2_4-in", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "Example2_4-out", CV_WINDOW_AUTOSIZE );
// Create a window to show our input image
//
cvShowImage( "Example2_4-in", image );
// Create an image to hold the smoothed output
//
IplImage* out = cvCreateImage(
cvGetSize(image),
IPL_DEPTH_8U,
3
);
// Do the smoothing
//
cvSmooth( image, out, CV_GAUSSIAN, 5,5 );
cvSmooth( out, out, CV_GAUSSIAN, 5, 5);
// Show the smoothed image in the output window
//
cvShowImage( "Example2_4-out", out );
// Be tidy
//
cvReleaseImage( &out );
// Wait for the user to hit a key, then clean up the windows
//
cvWaitKey( 0 );
cvDestroyWindow("Example2_4-in" );
cvDestroyWindow("Example2_4-out" );
}
int main( int argc, char** argv )
{
IplImage* img = cvLoadImage( argv[1] );
cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );
cvShowImage("Example1", img );
example2_4( img );
// cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow("Example1");
}
这是错误:
alberto @ zefiro:/ tmp $ g ++
pkg-config opencv --cflags --libs
ch2_ex2_4.cpp alberto @ zefiro:/ tmp $ ./a.out tree.avi OpenCV错误:错误的参数(数组应为CvMat或IplImage) cvGetSize,文件/build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp,第1233行在抛出'cv :: Exception'what()实例(/build/buildd/opencv-2.1)后终止。 0 / src / cxcore / cxarray.cpp:1233:错误:(-5)数组应为cvGetSize函数中的CvMat或IplImage中止
会是什么? 一些忠告?? 我没有修改示例,我刚刚下载了带有突触的opencv,所以我认为它是最新版本!
./a.out tree.avi
您正在传递视频文件,而样本需要图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.