I try to use teh cvBlob lib for blob detection, in opencv under Ubuntu but i got blocked right at the beginning. When i try to compile the example form there site:
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include "cvblob.h"
using namespace cvb;
using namespace std;
int main( int argc,char** argv){
if( argv[1] == NULL ){
printf("\n Please Provide a valid Argument \n");
return(0);
}
else{
IplImage* src = cvLoadImage(argv[1],CV_LOAD_IMAGE_UNCHANGED);
cvNamedWindow("Original",CV_WINDOW_AUTOSIZE);
cvShowImage("Original",src);
IplImage src_g;
cvThreshold(src, src_g,35,255, CV_THRESH_BINARY);
IplImage *labelImg=cvCreateImage(cvGetSize(src_g), IPL_DEPTH_LABEL, 1);
CvBlobs blobs;
unsigned int result=cvb::CvLabel(src_g, labelImg, blobs);
cvRenderBlobs(labelImg, blobs, src, src);
for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
{
cout << "Blob #" << it->second->label << ": Area=" << it->second->area << ", Centroid=(" << it->second->centroid.x << ", " << it->second->centroid.y << ")" << endl;
}
cvNamedWindow( "Mod", CV_WINDOW_AUTOSIZE );
cvShowImage( "Mod", src );
cvWaitKey(0);
cvReleaseImage(&src);
cvReleaseImage(&src_g);
cvDestroyWindow("Image");
return(0);
}
}
I get this error for this raw unsigned int result=cvb::CvLabel(src_g, labelImg, blobs);:
home/rrg/OpenCV-2.4.3/release/bagDetect/main.cpp: In function ‘int main(int, char**)’:
/home/rrg/OpenCV-2.4.3/release/bagDetect/main.cpp:28: error: functional cast expression list treated as compound expression
/home/rrg/OpenCV-2.4.3/release/bagDetect/main.cpp:28: error: invalid cast from type ‘cvb::CvBlobs’ to type ‘cvb::CvLabel’
make[2]: *** [CMakeFiles/bag.dir/main.o] Error 1
make[1]: *** [CMakeFiles/bag.dir/all] Error 2
make: *** [all] Error 2
I have no idea what should be the problem!
After the changes mentioned in the first answer i got a linker error :(
Linking CXX executable bag
CMakeFiles/bag.dir/main.o: In function `main':
main.cpp:(.text+0x103): undefined reference to `cvLabel'
main.cpp:(.text+0x134): undefined reference to `cvRenderBlobs'
collect2: ld returned 1 exit status
What and where should I put to be recognized the functions mentioned above?(CMakeList or Makefile)?