0

我正在编写的代码有一些问题,我正在尝试bwlabel用 C++ 进行操作。而且我遇到了一些内存释放问题,我不知道为什么,因为我尝试按照OpenCV 教程中的文档进行操作。似乎是变量的变量refcountproper有问题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;
}
4

1 回答 1

0

首先,尝试只使用 C++ 或 C 风格。你正在混合两者,它并不是很好。

cvConvertScale, Mat,IplImage等等。仅cv::Mat在可能的情况下使用并cv::仅发挥作用。

你有什么消息错误?

于 2013-04-18T23:13:11.467 回答