简体   繁体   English

从O'Reilly学习Opencv运行练习2-4时遇到问题

[英]Problem in running exercice 2-4 from Learning Opencv, O'Reilly

i'm studing the grat book Learning oPENCV, o'Reilly, from Bradsky and Kaehler. 我正在学习Bradsky和Kaehler的书《学习oPENCV,o'Reilly》。 i'm on Ubuntu 10.10, previous example works fine but in 2-4 i have a problem. 我在Ubuntu 10.10上,以前的示例工作正常,但在2-4中我有问题。

this is the code: 这是代码:

#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");
}

this is the error: 这是错误:

alberto@zefiro:/tmp$ g++ pkg-config opencv --cflags --libs ch2_ex2_4.cpp alberto@zefiro:/tmp$ ./a.out tree.avi OpenCV Error: Bad argument (Array should be CvMat or IplImage) in cvGetSize, file /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp, line 1233 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp:1233: error: (-5) Array should be CvMat or IplImage in function cvGetSize 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

Aborted 中止

what can it be?? 会是什么? some advice?? 一些忠告?? i have no modified the example and i've just downloaded opencv with synaptic so i think it is on the last version! 我没有修改示例,我刚刚下载了带有突触的opencv,所以我认为它是最新版本!

./a.out tree.avi

您正在传递视频文件,而样本需要图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM