SURF with Avi videos

asked 2013-01-29 11:19:14 -0500

updated 2013-01-29 11:42:27 -0500

Hi I am trying to apply SURF algorithm in AVI videos with size 175MB ~ 1405 frames ... I run the code and it is work for the first 52 frames then it is stop ,,,, Iam not sure what is the problem I got this error if I can the following code ... I am using this code on MAC os x 10.6.8 on openCV 2.4.0

The error OpenCV Error: Incorrect size of input array () in cvCreateSeq, file /Users/seereen2004/Desktop/OpenCV-2.4/modules/core/src/datastructs.cpp, line 372 terminate called after throwing an instance of 'cv::Exception' what(): /Users/seereen2004/Desktop/OpenCV-2.4/modules/core/src/datastructs.cpp:372: error: (-201) in function cvCreateSeq

Program received signal: “SIGABRT”. sharedlibrary apply-load-rules all Previous frame inner to this frame (gdb could not unwind past this frame) Previous frame inner to this frame (gdb could not unwind past this frame) (gdb)

The code :

#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/ml.h>
#include <opencv/cxcore.h>
#include <opencv/cv.h>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/calib3d/calib3d.hpp> 
#include <opencv2/imgproc/imgproc_c.h>


using namespace cv;

int main (int argc, char * const argv[])
{
    cv::initModule_nonfree();
    //cv::initModule_features2d();

    // GET video
    CvCapture* capture = cvCreateFileCapture( "/DVD_1/1_VTS_01_3.avi" );
    if (!capture ) 
    {
        printf( "Unable to read input video." );
        return 0;
    }

    double fps = cvGetCaptureProperty( capture,CV_CAP_PROP_FPS);
    // Read frame
    IplImage* frame = cvQueryFrame( capture );

    // INIT the video writer
    CvVideoWriter *writer = cvCreateVideoWriter( "surf.avi", CV_FOURCC('F','F','V','1'), fps, cvGetSize(frame));

    cvNamedWindow( "Example", CV_WINDOW_AUTOSIZE );
    static CvScalar red_color[] ={0,0,255};
    int c = 0 ; 

    while(1) 
    {
        CvMemStorage* storage = cvCreateMemStorage(0);
        CvSeq *imageKeypoints = 0, *imageDescriptors = 0;
        int i;

        //Extract SURF points by initializing parameters
        CvSURFParams params = cvSURFParams(100 , 1);
        cvExtractSURF( frame, 0, &imageKeypoints, &imageDescriptors, storage, params );
        //draw the keypoints on the captured frame
        for( i = 0; i < imageKeypoints->total; i++ )
        {
            CvSURFPoint* r = (CvSURFPoint*)cvGetSeqElem( imageKeypoints, i );
            CvPoint center;
            int radius;
            center.x = cvRound(r->pt.x);
            center.y = cvRound(r->pt.y);
            //radius = cvRound(r->size*1.2/9.*2);
            radius = 5;
            cvCircle( frame, center, radius, red_color[0], 1, 8, 0 );
        }

        cvWriteFrame( writer, frame );
        cvShowImage( "Example", frame );
        printf("\n frame number = %d", c);
        c++;
        cvClearMemStorage(storage); 
        cvReleaseMemStorage(&storage); 
        // READ next frame
        frame = cvQueryFrame( capture );
        if( !frame ) 
            break;

        char c = cvWaitKey(33);

        if( c == 27 ) 
            break;
    }

    // CLEAN everything
    cvReleaseImage( &frame );
    cvReleaseCapture( &capture );
    cvReleaseVideoWriter( &writer );
    cvDestroyWindow( "Example" );
    return 0;   
}
edit retag flag offensive close merge delete

Comments

some body tell me where is the problem ... pleeease :(

seereen2004 gravatar imageseereen2004 ( 2013-01-31 10:24:54 -0500 )edit