OpenCV Error: Assertion failed (std::abs(dsize.width*2 - ssize.width) <= 2
Please help me with this. I am working on Opencv as beginner.I am using Dev C++ please help me with this error Message" OpenCV Error: Assertion failed (std::abs(dsize.width*2 - ssize.width) <= 2
&& st d::abs(dsize.height*2 - ssize.height) <= 2) in pyrDown_, file C:\User\VP
\ocv\ope ncv\src\cv\cvpyramids.cpp, line 206
This application has requested the Runtime to terminate it in an unusual
way. Please contact the application's support team for more information.
Process exited with return value 3 Press any key to continue . . ." ....
My written code is here :
#include <cv.h>
#include<highgui.h>
//..........Rosenfeld80.................
IplImage* doPyrDown(IplImage *in,int filter= IPL_GAUSSIAN_5x5){
//make sure that input image is divisible by two using
assert(((int)in->width) % 2==0 && ((int)in->height) % 2==0);
IplImage *out=cvCreateImage(cvSize(in->depth/2,in->height/2),in->depth,in->nChannels);
cvPyrDown(in,out);
return (out);
}
//..........Canny edge detector [Canny86]............
IplImage * doCanny(IplImage* in, double lowThresh, double highThresh, double aperture){
if(in->nChannels !=1)// Canny works only with gray scale images
return 0;
IplImage *out=cvCreateImage(cvGetSize(in),IPL_DEPTH_8U,1);
cvCanny( in, out, lowThresh, highThresh, aperture );
return (out);
}
int main(int argc,char **argv){
IplImage* out;
IplImage* in=cvLoadImage("E:/Arshad/OpenCv/OpenCv Work/Penguins.jpg");
cvNamedWindow("Input",CV_WINDOW_AUTOSIZE);
cvShowImage("Input",in);
out =doPyrDown( in, IPL_GAUSSIAN_5x5 );
cvNamedWindow("doPyramidDown",CV_WINDOW_AUTOSIZE);
cvShowImage("doPyramidDown",out);
out = doPyrDown( out, IPL_GAUSSIAN_5x5 );
out = doCanny( out, 10, 100, 3 );
cvNamedWindow("doCanny",CV_WINDOW_AUTOSIZE);
cvShowImage("doCanny",out);
cvWaitKey(0);
cvReleaseImage(&out);
cvDestroyWindow("Input");
cvDestroyWindow("doPyramidDown");
cvDestroyWindow("doCanny");
}
first of all: please DO NOT use opencv's legacy C-api. this is a dead end.