IplImage to Mat refcount

时间:2013-04-18 22:55:26

标签: opencv

我在编写代码时遇到了一些问题,我正在尝试在C ++中进行bwlabel操作。而且我有一些内存释放问题,我不知道为什么,因为我试图遵循the OpenCV tutorials中的文档。 这似乎是变量refcount的变量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;
}

1 个答案:

答案 0 :(得分:0)

首先,尝试仅使用C ++或C样式。你混合两者并不是很好。

cvConvertScaleMatIplImage等等。如果可能,仅使用cv::Mat,仅使用cv::功能。

您有什么错误消息?

相关问题