Bjoern Froehlich 13 years ago
parent
commit
b1128f82d1
2 changed files with 10 additions and 5 deletions
  1. 7 5
      semseg/SemSegContextTree.cpp
  2. 3 0
      semseg/SemSegContextTree.h

+ 7 - 5
semseg/SemSegContextTree.cpp

@@ -52,7 +52,9 @@ SemSegContextTree::SemSegContextTree (const Config *conf, const MultiDataset *md
   
   useCategorization = conf->gB (section, "use_categorization", false);
   
-  if(useCategorization)
+  cndir = conf->gS ("SSContextTree", "cndir", "");
+  
+  if(useCategorization && cndir == "")
   {
     fasthik = new GPHIKClassifier(conf);
   }
@@ -1151,7 +1153,7 @@ void SemSegContextTree::train (const MultiDataset *md)
   
   cout << "uniquenumber " << uniquenumber << endl;
   
-  if(useCategorization)
+  if(useCategorization && fasthik != NULL)
   {
     uniquenumber = std::min(shortsize, uniquenumber);
     for(uint i = 0; i < globalCategorFeats.size(); i++)
@@ -1487,7 +1489,7 @@ void SemSegContextTree::semanticseg (CachedExample *ce, NICE::Image & segresult,
               currentfeats.set (x, y, forest[tree][t].left, tree);
 #pragma omp critical
               {
-                if(useCategorization && forest[tree][forest[tree][t].left].nodeNumber < uniquenumber)
+                if(fasthik != NULL && useCategorization && forest[tree][forest[tree][t].left].nodeNumber < uniquenumber)
                   (*globalCategorFeat)[forest[tree][forest[tree][t].left].nodeNumber] += weight;
               }
             }
@@ -1496,7 +1498,7 @@ void SemSegContextTree::semanticseg (CachedExample *ce, NICE::Image & segresult,
               currentfeats.set (x, y, forest[tree][t].right, tree);
 #pragma omp critical
               {
-                if(useCategorization && forest[tree][forest[tree][t].right].nodeNumber < uniquenumber)
+                if(fasthik != NULL && useCategorization && forest[tree][forest[tree][t].right].nodeNumber < uniquenumber)
                   (*globalCategorFeat)[forest[tree][forest[tree][t].right].nodeNumber] += weight;
               }
             }
@@ -1553,7 +1555,7 @@ void SemSegContextTree::semanticseg (CachedExample *ce, NICE::Image & segresult,
     }
   }
 
-  string cndir = conf->gS ("SSContextTree", "cndir", "");
+
 
   int allClasses = (int)probabilities.channels();
   vector<int> useclass (allClasses, 1);

+ 3 - 0
semseg/SemSegContextTree.h

@@ -108,6 +108,9 @@ class SemSegContextTree : public SemanticSegmentation, public NICE::Persistent
     
     /** use external image categorization to avoid some classes */
     bool useCategorization;
+    
+    /** categorization information for external categorization */
+    std::string cndir;
 
     /** how to handle each channel
      * 0: simple grayvalue features