|
@@ -25,6 +25,8 @@
|
|
|
#include <fstream>
|
|
|
#include <vector>
|
|
|
|
|
|
+#undef DEBUG
|
|
|
+
|
|
|
using namespace OBJREC;
|
|
|
|
|
|
using namespace NICE;
|
|
@@ -129,10 +131,10 @@ int main ( int argc, char **argv )
|
|
|
string resultdir = conf.gS ( "debug", "resultdir", "." );
|
|
|
/*-------------------------------------------*/
|
|
|
|
|
|
- if ( write_results )
|
|
|
- {
|
|
|
- cerr << "Writing Results to " << resultdir << endl;
|
|
|
- }
|
|
|
+#ifdef DEBUG
|
|
|
+ cerr << "Writing Results to " << resultdir << endl;
|
|
|
+#endif
|
|
|
+
|
|
|
|
|
|
MultiDataset md ( &conf );
|
|
|
|
|
@@ -143,6 +145,8 @@ int main ( int argc, char **argv )
|
|
|
semseg = new SemSegContextTree ( &conf, &md );
|
|
|
|
|
|
// train semantic segmentation method
|
|
|
+ cout << "\nTRAINING" << endl;
|
|
|
+ cout << "########\n" << endl;
|
|
|
semseg->train( &md );
|
|
|
|
|
|
const LabeledSet *testFiles = md["test"];
|
|
@@ -164,6 +168,8 @@ int main ( int argc, char **argv )
|
|
|
NICE::MultiChannelImageT<double> gt;
|
|
|
std::vector< NICE::Matrix > M_vec;
|
|
|
|
|
|
+ cout << "\nCLASSIFICATION" << endl;
|
|
|
+ cout << "##############\n" << endl;
|
|
|
for (LabeledSet::const_iterator it = testFiles->begin(); it != testFiles->end(); it++)
|
|
|
{
|
|
|
for (std::vector<ImageInfo *>::const_iterator jt = it->second.begin();
|
|
@@ -187,7 +193,9 @@ int main ( int argc, char **argv )
|
|
|
lm_gt.set ( 0 );
|
|
|
|
|
|
l_gt->calcLabeledImage ( lm, classNames.getBackgroundClass() );
|
|
|
- fprintf ( stderr, "testSemanticSegmentation: Generating Labeled NICE::Image (Ground-Truth)\n" );
|
|
|
+#ifdef DEBUG
|
|
|
+ cout << "testSemanticSegmentation: Generating Labeled NICE::Image (Ground-Truth)" << endl;
|
|
|
+#endif
|
|
|
l_gt->calcLabeledImage ( lm_gt, classNames.getBackgroundClass() );
|
|
|
}
|
|
|
segresult.addChannel ( lm );
|
|
@@ -203,14 +211,9 @@ int main ( int argc, char **argv )
|
|
|
|
|
|
NICE::MultiChannelImage3DT<double> probabilities;
|
|
|
NICE::MultiChannelImage3DT<double> imgData;
|
|
|
- semseg->make3DImage ( filelist, imgData );
|
|
|
|
|
|
- Timer timer;
|
|
|
- timer.start();
|
|
|
+ semseg->make3DImage ( filelist, imgData );
|
|
|
semseg->classify ( imgData, segresult, probabilities, filelist );
|
|
|
- timer.stop();
|
|
|
-
|
|
|
- fprintf ( stderr, "testSemanticSegmentation: Segmentation finished in %f seconds!\n", timer.getLastAbsolute() );
|
|
|
|
|
|
// save to file
|
|
|
for ( int z = 0; z < segresult.channels(); z++ )
|
|
@@ -267,23 +270,15 @@ int main ( int argc, char **argv )
|
|
|
out << resultdir << "/" << fname << output_postfix;
|
|
|
else
|
|
|
out << resultdir << "/" << fname;
|
|
|
-
|
|
|
- cerr << "Writing to file " << out.str() << "_*." << output_type << endl;
|
|
|
+#ifdef DEBUG
|
|
|
+ cout << "Writing to file " << out.str() << "_*." << output_type << endl;
|
|
|
+#endif
|
|
|
orig.write ( out.str() + "_orig." + output_type );
|
|
|
rgb.write ( out.str() + "_result." + output_type );
|
|
|
rgb_gt.write ( out.str() + "_groundtruth." + output_type );
|
|
|
ov_rgb.write ( out.str() + "_overlay_res." + output_type );
|
|
|
ov_rgb_gt.write ( out.str() + "_overlay_gt." + output_type );
|
|
|
}
|
|
|
-
|
|
|
- if ( show_result )
|
|
|
- {
|
|
|
-#ifndef NOVISUAL
|
|
|
- showImage ( ov_rgb, "Result" );
|
|
|
- showImage ( ov_rgb_gt, "Groundtruth" );
|
|
|
- showImage ( orig, "Input" );
|
|
|
-#endif
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -300,9 +295,14 @@ int main ( int argc, char **argv )
|
|
|
segresult.freeData();
|
|
|
// pb.hide();
|
|
|
|
|
|
+ cout << "\nSTATISTICS" << endl;
|
|
|
+ cout << "##########\n" << endl;
|
|
|
long maxMemory;
|
|
|
- rs.getMaximumMemory ( maxMemory );
|
|
|
- cerr << "Maximum memory used: " << maxMemory << " KB" << endl;
|
|
|
+ double userCPUTime, sysCPUTime;
|
|
|
+ rs.getStatistics ( maxMemory, userCPUTime, sysCPUTime );
|
|
|
+ cout << "Memory (max): " << maxMemory << " KB" << endl;
|
|
|
+ cout << "CPU Time (user): " << userCPUTime << " seconds" << endl;
|
|
|
+ cout << "CPU Time (sys): " << sysCPUTime << " seconds" << endl;
|
|
|
|
|
|
double overall = 0.0;
|
|
|
double sumall = 0.0;
|
|
@@ -360,13 +360,17 @@ int main ( int argc, char **argv )
|
|
|
}
|
|
|
|
|
|
// print/save results of evaluation
|
|
|
+ cout << "\nPERFORMANCE" << endl;
|
|
|
+ cout << "###########\n" << endl;
|
|
|
ofstream fout ( ( resultdir + "/res.txt" ).c_str(), ios::out );
|
|
|
- fout << "overall: " << overall << endl;
|
|
|
- fout << "Average Performance " << avg_perf / ( classes_trained ) << endl;
|
|
|
- fout << "Lower Bound " << 1.0 / classes_trained << endl;
|
|
|
- fprintf ( stderr, "overall: %f\n", overall );
|
|
|
- fprintf ( stderr, "Average Performance %f\n", avg_perf / ( classes_trained ) );
|
|
|
- fprintf(stderr, "Lower Bound %f\n", 1.0 / classes_trained);
|
|
|
+ fout << "Overall Recognition Rate: " << overall << endl;
|
|
|
+ fout << "Average Recognition Rate: " << avg_perf / ( classes_trained ) << endl;
|
|
|
+ fout << "Lower Bound: " << 1.0 / classes_trained << endl;
|
|
|
+ cout << "Overall Recogntion Rate: " << overall << endl;
|
|
|
+ cout << "Average Recogntion Rate: " << avg_perf / ( classes_trained ) << endl;
|
|
|
+ cout << "Lower Bound: " << 1.0 / classes_trained << endl;
|
|
|
+
|
|
|
+ cout <<"\nClasses:" << endl;
|
|
|
for ( int r = 0 ; r < ( int ) M.rows() ; r++ )
|
|
|
{
|
|
|
if ( ( classNames.existsClassno ( r ) ) && ( forbidden_classes.find ( r ) == forbidden_classes.end() ) )
|