App crashes because of a cvAddWeighted(...) statement

36 views
Skip to first unread message

Shishir

unread,
Aug 7, 2012, 7:15:42 AM8/7/12
to android...@googlegroups.com
I'm using OpenCV in native code for my Gingerbread app, and it's crashing at the statement cvAddWeighted(...)
        cvSetImageROI(image2,faces1);//faces1 is of type CvRect
       
IplImage *temp1 = cvLoadImage(filepath1);
       
IplImage *temp2 = cvCreateImage(cvSize(faces1.width,faces1.height),temp1->depth,temp1->nChannels);
        cvResize
(temp1,temp2);
       
cvAddWeighted(image2,alpha,temp2,beta,0.0,image2);//cvCopy(temp2,image2);//
        cvReleaseImage
(&temp2);
        cvReleaseImage
(&temp1);
        cvResetImageROI
(image2);
I tested the code only for values of alpha and beta that satisfies beta = 1.0 - alpha, and the app crashes. I found out that it crashes because of the line cvAddWeighted by commenting out the entire block, and then uncommenting one successive line at a time. I also replaced the cvAddWeighted() call with a cvCopy(), but even then the app crashes. Any idea why?

Andrey Pavlenko

unread,
Aug 7, 2012, 11:11:51 AM8/7/12
to android...@googlegroups.com
Check if `temp2` has the same `depth` and `nChannels` as `image2`.

Shishir

unread,
Aug 8, 2012, 1:23:50 AM8/8/12
to android...@googlegroups.com
Checked, all the images have the same depth, number of channels and all images are BGR images.
Reply all
Reply to author
Forward
0 new messages