我正在编写的代码有一些问题,我正在尝试bwlabel
用 C++ 进行操作。而且我遇到了一些内存释放问题,我不知道为什么,因为我尝试按照OpenCV 教程中的文档进行操作。似乎是变量的变量refcount
proper有问题Mat
。
这是我的代码:
void VideoSeg::bwlabel(IplImage *srce, IplImage *out)
{
namedWindow( "wndNameOut", CV_GUI_NORMAL );
cvConvertScale(srce,srce,255.);
Ptr<IplImage> srcx = srce;
Mat src(srcx);
imshow( "wndNameOut", src); //The image is succesfully plotted
SimpleBlobDetector blobDetector( params );
blobDetector.create("SimpleBlob");
blobDetector.detect(src, keyPoints ); // The problem appears in this line
for(int i=0; i<keyPoints.size(); i++ )
{
cv::floodFill(src,keyPoints[i].pt, Scalar::all((i+1)*255/(keyPoints.size()+1)));
}
IplImage outx = src;
//http://docs.opencv.org/doc/tutorials/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.html
(*out) = outx;
cout << "Keypoints " << keyPoints.size() << endl;
}