简体   繁体   中英

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. i'm on Ubuntu 10.10, previous example works fine but in 2-4 i have a problem.

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

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!

./a.out tree.avi

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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