|
@@ -243,72 +243,72 @@ void SemSegTools::collectTrainingExamples (
|
|
|
|
|
|
if ( useExcludedAsBG )
|
|
|
{
|
|
|
- backgroundClassNo = cn.classno("various");
|
|
|
- assert ( backgroundClassNo >= 0 );
|
|
|
+ backgroundClassNo = cn.classno("various");
|
|
|
+ assert ( backgroundClassNo >= 0 );
|
|
|
}
|
|
|
|
|
|
LOOP_ALL_S (train)
|
|
|
{
|
|
|
- EACH_INFO(image_classno,imgInfo);
|
|
|
- std::string imgfn = imgInfo.img();
|
|
|
-
|
|
|
- if ( ! imgInfo.hasLocalizationInfo() ) {
|
|
|
- fprintf (stderr, "WARNING: NO localization info found for %s !\n",
|
|
|
- imgfn.c_str() );
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- int xsize, ysize;
|
|
|
- CachedExample *ce = new CachedExample ( imgfn );
|
|
|
- ce->getImageSize ( xsize, ysize );
|
|
|
- imgexamples.push_back ( ce );
|
|
|
-
|
|
|
- const LocalizationResult *locResult = imgInfo.localization();
|
|
|
- if ( locResult->size() <= 0 ) {
|
|
|
- fprintf (stderr, "WARNING: NO ground truth polygons found for %s !\n",
|
|
|
- imgfn.c_str());
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- fprintf (stderr, "SemSegTools: Collecting pixel examples from localization info: %s\n",
|
|
|
- imgfn.c_str() );
|
|
|
-
|
|
|
- NICE::Image pixelLabels (xsize, ysize);
|
|
|
- pixelLabels.set(0);
|
|
|
- locResult->calcLabeledImage ( pixelLabels, cn.getBackgroundClass() );
|
|
|
-
|
|
|
-#ifdef DEBUG_LOCALIZATION
|
|
|
- NICE::Image img (imgfn);
|
|
|
- showImage(img);
|
|
|
- showImage(pixelLabels);
|
|
|
-#endif
|
|
|
+ EACH_INFO(image_classno,imgInfo);
|
|
|
+ std::string imgfn = imgInfo.img();
|
|
|
+
|
|
|
+ if ( ! imgInfo.hasLocalizationInfo() ) {
|
|
|
+ std::cerr << "WARNING: NO localization info found for "
|
|
|
+ << imgfn << " !" << std::endl;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ int xsize, ysize;
|
|
|
+ CachedExample *ce = new CachedExample ( imgfn );
|
|
|
+ ce->getImageSize ( xsize, ysize );
|
|
|
+ imgexamples.push_back ( ce );
|
|
|
+
|
|
|
+ const LocalizationResult *locResult = imgInfo.localization();
|
|
|
+ if ( locResult->size() <= 0 ) {
|
|
|
+ std::cerr << "WARNING: NO ground truth polygons found for "
|
|
|
+ << imgfn << " !" << std::endl;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- Example pce ( ce, 0, 0 );
|
|
|
- for ( int x = 0 ; x < xsize ; x += grid_size_x )
|
|
|
- for ( int y = 0 ; y < ysize ; y += grid_size_y )
|
|
|
- {
|
|
|
- if ( (x >= grid_border_x) &&
|
|
|
- ( y >= grid_border_y ) && ( x < xsize - grid_border_x ) &&
|
|
|
- ( y < ysize - grid_border_x ) )
|
|
|
- {
|
|
|
- pce.x = x; pce.y = y;
|
|
|
- int classno = pixelLabels.getPixel(x,y);
|
|
|
-
|
|
|
- if ( classnoSelection.find(classno) != classnoSelection.end() ) {
|
|
|
- examples.push_back ( pair<int, Example> (
|
|
|
- classno,
|
|
|
- pce // FIXME: offset handling
|
|
|
- ) );
|
|
|
- } else if ( useExcludedAsBG ) {
|
|
|
- examples.push_back ( pair<int, Example> (
|
|
|
- backgroundClassNo,
|
|
|
- pce // FIXME: offset handling
|
|
|
- ) );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ std::cerr << "SemSegTools: Collecting pixel examples from localization info: "
|
|
|
+ << imgfn << std::endl;
|
|
|
+
|
|
|
+ NICE::Image pixelLabels (xsize, ysize);
|
|
|
+ pixelLabels.set(0);
|
|
|
+ locResult->calcLabeledImage ( pixelLabels, cn.getBackgroundClass() );
|
|
|
+
|
|
|
+ #ifdef DEBUG_LOCALIZATION
|
|
|
+ NICE::Image img (imgfn);
|
|
|
+ showImage(img);
|
|
|
+ showImage(pixelLabels);
|
|
|
+ #endif
|
|
|
+
|
|
|
+ Example pce ( ce, 0, 0 );
|
|
|
+ for ( int x = 0 ; x < xsize ; x += grid_size_x )
|
|
|
+ for ( int y = 0 ; y < ysize ; y += grid_size_y )
|
|
|
+ {
|
|
|
+ if ( (x >= grid_border_x) &&
|
|
|
+ ( y >= grid_border_y ) && ( x < xsize - grid_border_x ) &&
|
|
|
+ ( y < ysize - grid_border_x ) )
|
|
|
+ {
|
|
|
+ pce.x = x; pce.y = y;
|
|
|
+ int classno = pixelLabels.getPixel(x,y);
|
|
|
+
|
|
|
+ if ( classnoSelection.find(classno) != classnoSelection.end() ) {
|
|
|
+ examples.push_back ( pair<int, Example> (
|
|
|
+ classno,
|
|
|
+ pce // FIXME: offset handling
|
|
|
+ ) );
|
|
|
+ } else if ( useExcludedAsBG ) {
|
|
|
+ examples.push_back ( pair<int, Example> (
|
|
|
+ backgroundClassNo,
|
|
|
+ pce // FIXME: offset handling
|
|
|
+ ) );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- fprintf (stderr, "total number of examples: %d\n", (int)examples.size() );
|
|
|
+ std::cerr << "total number of examples: " << (int)examples.size() << std::endl;
|
|
|
}
|
|
|
|