[Jderobot-admin] jderobot-r974 - trunk/src/stable/components/rgbdCalibrator

rocapal en jderobot.org rocapal en jderobot.org
Mie Ago 14 12:28:17 CEST 2013


Author: rocapal
Date: 2013-08-14 12:27:17 +0200 (Wed, 14 Aug 2013)
New Revision: 974

Modified:
   trunk/src/stable/components/rgbdCalibrator/CMakeLists.txt
   trunk/src/stable/components/rgbdCalibrator/rgbdCalibrator.cpp
   trunk/src/stable/components/rgbdCalibrator/viewer.cpp
Log:
#27 added filter blobs with cvBlob


Modified: trunk/src/stable/components/rgbdCalibrator/CMakeLists.txt
===================================================================
--- trunk/src/stable/components/rgbdCalibrator/CMakeLists.txt	2013-08-14 09:11:01 UTC (rev 973)
+++ trunk/src/stable/components/rgbdCalibrator/CMakeLists.txt	2013-08-14 10:27:17 UTC (rev 974)
@@ -23,4 +23,5 @@
     ${LIBS_DIR}/progeo/libprogeo.so
     ${LIBS_DIR}/geometry/libgeometry.so
     ${LIBS_DIR}/colorspaces/libcolorspaces.so
+    ${LIBS_DIR}/cvBlob/libcvblob.so
 )

Modified: trunk/src/stable/components/rgbdCalibrator/rgbdCalibrator.cpp
===================================================================
--- trunk/src/stable/components/rgbdCalibrator/rgbdCalibrator.cpp	2013-08-14 09:11:01 UTC (rev 973)
+++ trunk/src/stable/components/rgbdCalibrator/rgbdCalibrator.cpp	2013-08-14 10:27:17 UTC (rev 974)
@@ -70,7 +70,7 @@
 				  &(data->pixelData[0]));
 
 
-      
+      /*
       jderobot::ImageDataPtr data2 = cprxDepth->getImageData();
       colorspaces::Image::FormatPtr fmt2 =  colorspaces::Image::Format::searchFormat(data2->description->format);
       if (!fmt2)
@@ -80,13 +80,16 @@
 				  data2->description->height,
 				  fmt2,
 				  &(data2->pixelData[0]));
+      */
 
-      viewer.setDepth(cprxDepth->getImageData());
-      viewer.display(imgColor, imgDepth);
+      //viewer.setDepth(NULL);//cprxDepth->getImageData());
 
 
+      viewer.display(imgColor, imgColor);
 
 
+
+
       
 
     }

Modified: trunk/src/stable/components/rgbdCalibrator/viewer.cpp
===================================================================
--- trunk/src/stable/components/rgbdCalibrator/viewer.cpp	2013-08-14 09:11:01 UTC (rev 973)
+++ trunk/src/stable/components/rgbdCalibrator/viewer.cpp	2013-08-14 10:27:17 UTC (rev 974)
@@ -25,12 +25,14 @@
 #include <IceUtil/IceUtil.h>
 #include <boost/filesystem.hpp>
 #include "calibration.h"
+#include "../../libs/cvBlob/cvblob.h"
 
 #define DEGTORAD     (3.14159264 / 180.0)
 #define DEBUG TRUE
 
 using namespace boost::filesystem; 
 using namespace cv;
+using namespace cvb;
 
 namespace rgbdCalibrator{
   
@@ -106,7 +108,7 @@
     if (intrinsicsEnable)
       saveImage(imageColor);
     
-
+    
     pthread_mutex_lock(&mutex);
     imgOrig.create(imageColor.size(), CV_8UC3);
     imageColor.copyTo(imgOrig);
@@ -146,6 +148,8 @@
 
     imgHSV.create(imgOrig.size(), CV_8UC1);
     imgOrig.copyTo(imgHSV);
+
+    IplImage *threshy=cvCreateImage(imgOrig.size(),8,1);
     
     for (int i=0;i< imgHSV.size().width*imgHSV.size().height; i++)
     {
@@ -159,12 +163,54 @@
 	  && smax >= hsvData->S && smin <= hsvData->S
 	  && vmax >= hsvData->V && vmin <=  hsvData->V )
       {
+	threshy->imageData[i] = 1;
       }
       else
+      {
 	imgHSV.data[i*3] = imgHSV.data[i*3+1] = imgHSV.data[i*3+2] = 0;
+	threshy->imageData[i] = 0;
+      }
+      
 
     }
+
+    //Structure to hold blobs
+    CvBlobs blobs;
+
+    IplImage *iplOrig = new IplImage(imgOrig);
+    IplImage *frame=cvCreateImage(imgOrig.size(),8,3);
+    IplImage *labelImg=cvCreateImage(imgOrig.size(),IPL_DEPTH_LABEL,1);
+
+    cvResize(iplOrig,frame,CV_INTER_LINEAR );
+
+    //Threshy is a binary image
+    cvSmooth(threshy,threshy,CV_MEDIAN,7,7);
+
+    //Finding the blobs
+    unsigned int result=cvLabel(threshy,labelImg,blobs);
+
+    //Rendering the blobs
+    cvRenderBlobs(labelImg,blobs,frame,frame);
+
+    //Filter Blobs
+    cvFilterByArea(blobs,300,1000);    
+
+    for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
+    {
+      std::cout << "BLOB found: " << it->second->area  <<std::endl;
+      double moment10 = it->second->m10;
+      double moment01 = it->second->m01;
+      double area = it->second->area;
       
+    }
+
+    cvShowImage("Live",frame);
+
+    // Release and free memory
+    delete(iplOrig);
+    cvReleaseImage(&threshy);
+    cvReleaseImage(&frame);
+    cvReleaseImage(&labelImg);
   }
 
   void Viewer::setDepth(const jderobot::ImageDataPtr depth)



More information about the Jderobot-admin mailing list