I am having trouble with cvPyrMeansShiftFiltering() function in OpenCV. Any call to it results in an "Assertion failed" message.
The following code fails on the line that calls cvPryMeanShiftFiltering:
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
#include <iostream>
using namespace std;
int main()
{
string imageFile = "..\\bear.jpg";
IplImage* src = cvLoadImage(imageFile.c_str());
int width = src->width;
int height = src->height;
IplImage* result = cvCreateImage(cvSize(width,height),8,3);
cvPyrMeanShiftFiltering(src,result,4.0,4.0,0);
cvReleaseImage(&src);
cvReleaseImage(&result);
return 0;
}
The program runs until the following error message is sent to the console:
OpenCV Error: Assertion failed (udata < (uchar*)ptr && ((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+16)) in unknown function, file ......\src\cxcore\cxalloc.cpp, line 76
The assertion that fails is in cv::fastFree() in cxalloc.cpp. The program is running on Windows 7 (64bit), on VS 2008. The OpenCV version is 2.0.
I'll add that I've also tried this with OpenCV 2.1 on both VS2008 and VS2010. So it must be something that I'm doing, right? Why am I getting this error?