Ver código fonte

some corrections in SemSegTools

Sven Sickert 9 anos atrás
pai
commit
b5a2682804
2 arquivos alterados com 10 adições e 12 exclusões
  1. 8 11
      semseg/SemSegTools.cpp
  2. 2 1
      semseg/SemSegTools.h

+ 8 - 11
semseg/SemSegTools.cpp

@@ -99,18 +99,13 @@ void SemSegTools::computeClassificationStatistics(
     std::cout << "\nPERFORMANCE" << std::endl;
     std::cout << "###########\n" << std::endl;
 
-    double overallTrue = 0.0;
+    double overallTrue = confMat.trace();
     double sumAll  = 0.0;
 
     // overall recognition rate
     for ( int r = 0; r < (int) confMat.rows(); r++ )
         for ( int c = 0; c < (int) confMat.cols(); c++ )
-        {
-            if ( r == c )
-                overallTrue += confMat( r, c );
-
             sumAll += confMat( r, c );
-        }
 
     overallTrue /= sumAll;
 
@@ -125,9 +120,9 @@ void SemSegTools::computeClassificationStatistics(
         double precision = truePos / (truePos+falsePos);
         double recall = truePos / (truePos+falseNeg);
         double f1score = 2.0*(precision*recall)/(precision+recall);
-        std::cout << "\nPrecision: " << precision;
+        std::cout << "Precision: " << precision;
         std::cout << "\nRecall: " << recall;
-        std::cout << "\nF1Score: " << f1score;
+        std::cout << "\nF1Score: " << f1score << "\n\n";
     }
 
     // normalizing confMat using rows
@@ -175,8 +170,8 @@ void SemSegTools::computeClassificationStatistics(
     }
 
     // print classification statistics
-    std::cout << "\nOverall Recogntion Rate: " << overallTrue;
-    std::cout << "\nAverage Recogntion Rate: " << confMat.trace() / (double)classMappingInv.size();
+    std::cout << "\nOverall Recognition Rate: " << overallTrue;
+    std::cout << "\nAverage Recognition Rate: " << confMat.trace() / (double)classMappingInv.size();
     std::cout << "\nLower Bound: " << 1.0 /(double)classMappingInv.size();
     std::cout << std::endl;
 }
@@ -187,7 +182,8 @@ void SemSegTools::saveResultsToImageFile(
         const ColorImage &orig,
         const ColorImage &gtruth,
         const ColorImage &segment,
-        const string &file )
+        const string &file,
+        string & outStr )
 {
     std::string resultDir = conf->gS ( section, "resultdir", "." );
     std::string outputType = conf->gS ( section, "output_type", "ppm" );
@@ -212,6 +208,7 @@ void SemSegTools::saveResultsToImageFile(
     overlaySegment.write ( out.str() + "_overlay_res." + outputType );
     overlayGTruth.write ( out.str() + "_overlay_gt." + outputType );
 
+    outStr = out.str();
 }
 
 void SemSegTools::collectTrainingExamples ( 

+ 2 - 1
semseg/SemSegTools.h

@@ -78,7 +78,8 @@ class SemSegTools
             const NICE::ColorImage & orig,
             const NICE::ColorImage & gtruth,
             const NICE::ColorImage & segment,
-            const std::string & file );
+            const std::string & file,
+            std::string & outStr );
 
     /** collect pixel-wise training examples
         from a set of images