0

I'm trying to detect a blob on a video feed with cvBlob lib in my ROS node. I think, I made a mistake with pointers, but I can't figure out where. Moreover, do I have to free some of this variable?

Mat& corridorProces(Mat& resultImg)
{   
    Mat srcMat=resultImg.clone();
    cvtColor( resultImg, resultImg, CV_RGB2GRAY );
    IplImage src= resultImg.clone();
    IplImage *src_g= new IplImage(src);
    IplImage *src_g_inv=new IplImage(src);
    cvThreshold(src_g, src_g_inv,35,255, CV_THRESH_BINARY_INV);
    cvThreshold(src_g, src_g,40,255, CV_THRESH_BINARY);    
    IplImage *labelImg=cvCreateImage(cvGetSize(src_g), IPL_DEPTH_LABEL, 1);
    cvb::CvBlobs blobs;
    unsigned int result=cvb::cvLabel(src_g, labelImg, blobs);   
...
}
Elod
  • 499
  • 9
  • 25

1 Answers1

0

You need to use cvCopy to copy an image to another. Furthermore, You need to release the images using cvReleaseImage(&image);

andre_lamothe
  • 2,171
  • 2
  • 41
  • 74
  • thanks @Ahmed Saleh, I used `IplImage *src_g=cvCloneImage(&src);` and now its working. – Elod Mar 07 '13 at 13:34