我正在研究布拉德斯基和凯勒的“学习oPENCV,O‘’Reilly”一书。我在Ubuntu10.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");
}这是一个错误:
/build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp,文件:
alberto@zefiro:/tmp$ g++
pkg-config opencv --cflags --libsch2_ex2_4.cpp alberto@zefiro:/tmp$ ./a.out tree.avi OpenCV错误:坏参数(数组应该是CvMat或IplImage)第1233行在抛出'cv::Exception‘实例之后调用/build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp:1233:错误:(-5)数组应该是函数cvGetSize中的CvMat或IplImage
已中止
会是什么??有什么建议?我没有修改这个例子,我刚刚用synaptic下载了opencv,所以我认为它是在最后一个版本上!
发布于 2011-08-24 16:09:38
./a.out tree.avi您正在传递一个视频文件,而示例需要一个图像。
https://stackoverflow.com/questions/7178517
复制相似问题