0

I´m having some problems with a code I'm writing, I'm trying to make the bwlabel operation in C++. And I'm having some memory deallocation problems, I don't know why, because I tried to follow the documentation in the OpenCV tutorials. It seems to be a problem with the variable refcount proper of the variable Mat.

Here is my code:

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;
}
Angie Quijano
  • 4,167
  • 3
  • 25
  • 30

1 Answers1

0

First, Try to only C++ or C style. You are mixing both and it not really good.

cvConvertScale, Mat, IplImage and more. Use only cv::Mat if possible and cv:: function only.

What is the message error you have?

Angie Quijano
  • 4,167
  • 3
  • 25
  • 30
Vuwox
  • 2,331
  • 18
  • 33
  • Thank your answer @Alexandre Bizeau , i know i'm mixing functions of different versions of opencv, but i can't change that. The problem i'm getting is a memory problem when the code reach that line i marked before. – Santiago Molina Apr 18 '13 at 23:22
  • It`s a OpenCV assertion failed ? Memory Violation ? Memory leak ? – Vuwox Apr 18 '13 at 23:52
  • this is the error i get Unhandled exception at 0x7543c41f in Online_video_segmenter.exe: Microsoft C++ exception: cv::Exception at memory location 0x0013da54.. – Santiago Molina Apr 19 '13 at 15:17
  • Can I have the details of keyPoints ? – Vuwox Apr 19 '13 at 15:30
  • It declare as a member variable ? – Vuwox Apr 19 '13 at 16:32
  • Try to have a look to this answer : http://stackoverflow.com/questions/8076889/tutorial-on-opencv-simpleblobdetector, SimpleBLobDetector is a cv::Ptr. Maybe it can be the problem. I have never work with FeatureDetector of OpenCV. But if you need your answer fast try to post here : [OpenCV Q&A](http://answers.opencv.org/questions/) – Vuwox Apr 19 '13 at 16:37
  • Thank you very much for your interest, i already tried but didn't work, i'm going to write in the other forum as u say – Santiago Molina Apr 19 '13 at 17:05