OpenCV Error: Assertion failed (std::abs(dsize.width*2 - ssize.width) <= 2 && std::abs(dsize.height*2 - ssize.height) <= 2)

asked 2015-12-21 15:43:07 -0500

args gravatar image

I'm using Xcode on macPro, I got this error but every things looks good. any one can help?

include <opencv highgui.h="">

include <opencv cv.h="">

include <iostream>

IplImage* doPyrDown(IplImage* in, int filter = IPL_GAUSSIAN_5x5){ assert(in->width%2 == 0 && in->height%2 == 0); IplImage* out = cvCreateImage(cvSize(in->width, in->height), in->depth, in->nChannels); cvPyrDown(in, out); return out; } int main(int argc, char* argv) { IplImage img = cvLoadImage("/Users/Downloads/opencv.png"); IplImage* img1 = doPyrDown(img, IPL_GAUSSIAN_5x5); imageDisplay(img1); }

edit retag flag offensive close merge delete

Comments

please do not use opencv's deprecated c-api (IplImage*) but c++ (cv::Mat)

the result image for pydown must be half the size of the input, you got that wrong.

again, please rewite it from scratch in c++ , where you do not have to pre-allocate result Mat's, thus your error won't happen there.

berak gravatar imageberak ( 2015-12-22 01:34:10 -0500 )edit