First time here? Check out the FAQ!

Ask Your Question
2

OpenCV Error:Assertion failed alloc.cpp,line 76

asked Sep 13 '12

Jerry Yu gravatar image

updated Sep 13 '12

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.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Sep 13 '12

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.

Preview: (hide)

Question Tools

Stats

Asked: Sep 13 '12

Seen: 2,273 times

Last updated: Sep 13 '12