我正在编写的代码有一些问题,我试图在C++中进行bwlabel操作。我遇到了一些内存释放问题,我不知道为什么,因为我试图遵循the OpenCV tutorials中的文档。这似乎是因为变量Mat的变量refcount本身有问题。
下面是我的代码:
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;
}发布于 2013-04-19 07:13:11
首先,尝试只使用C++或C样式。你把两个都混在一起了,这并不是很好。
cvConvertScale、Mat、IplImage等等。如果可能,仅使用cv::Mat和cv::函数。
您收到的错误消息是什么?
https://stackoverflow.com/questions/16094427
复制相似问题