Ask Your Question
2

OpenCV Error:Assertion failed alloc.cpp,line 76

asked 2012-09-13 00:35:18 -0600

Jerry Yu gravatar image

updated 2012-09-13 09:34:01 -0600

Andrey Pavlenko gravatar image

I try the following code using OpenCV 2.3.1 and it fails when attempting to return in main().

typedef struct window
{
    int height;
    int width;
    double scale;
    struct window *next;    
} window;

int main()
{   
        CvSVM svm=CvSVM();
        svm.load("SVM_DATA2.xml");
        IplImage *p=cvLoadImage("C:\\1\\result2\\image_00050.png",-1);
        struct window *head,*q;
        head=descriptor(p,1.1,svm);
        for(q=head;q!=NULL;q=q->next)
        {                       
           cvRectangle(p, cvPoint(q->width,q->height), cvPoint(q->width+cvFloor(64*q->scale),q->height+cvFloor(128*q->scale)), cvScalar(0,0,255), 1);   
        }   
        cvNamedWindow("svm", CV_WINDOW_AUTOSIZE); 
        cvMoveWindow("svm", 100, 100); 
        cvShowImage("svm", p ); 
        cvWaitKey(0); 
        cvReleaseImage(&p );
        return 0;
}

and gives the message (VS2008 Windows 7)

OpenCV Error: Assertion failed (udata < (uchar*)ptr && ((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+16)) in unknown function, file ..\..\..\src\opencv\mod ules\core\src\alloc.cpp, line 76.

So,I tried some break point,when i come to the bottom line" return 0" it shows cv::Exception. I am a freshman and will waiting for any advice.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2012-09-13 08:29:40 -0600

unxnut gravatar image

This error happens because you may end up sending invalid values into a function of OpenCV. Since your code is simple enough, I'll suggest that you look at the different input parameters for function calls and make sure that they are correct.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-09-13 00:35:18 -0600

Seen: 2,243 times

Last updated: Sep 13 '12