0
$\begingroup$

Rosanswers logo

I'm trying to detect a blob on a video feed with cvBlob lib. 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? The problem appears in row: unsigned int result=cvb::cvLabel(src_g, labelImg, blobs);

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);   
...
}

Originally posted by zweistein on ROS Answers with karma: 231 on 2013-03-06

Post score: 0


Original comments

Comment by Miquel Massot on 2013-03-06:
This question is not related to ROS. It's better suited in cvBlob project mailing list or similar, not here.

Comment by phbou72 on 2013-03-06:
Simply comment out all the code inside the function, and uncomment line by line until you find the one that give you a segmentation fault. It's not something related to ROS. It's a programming issue.

Comment by zweistein on 2013-03-06:
The weird thing is that the algorithm implenented in Opencv works for 1 image, but when I try it in ROS, where the cv_brigde returns a cv::MAT() and I convert into Iplimage, I receive segmentation fault error.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I changed to: IplImage *src_g=cvCloneImage(&src); and now its working. I dont understand why I got some times empty packages but now there is no more segmentation fault.


Originally posted by zweistein with karma: 231 on 2013-03-07

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.