Johannes Ruehle 11 năm trước cách đây
mục cha
commit
a24e6b7d8a

+ 71 - 0
classifier/GenericFPClassifierSelection.h

@@ -0,0 +1,71 @@
+#ifndef _NICE_OBJREC_GENERICFPCLASSIFIERSELECTION_INCLUDE
+#define _NICE_OBJREC_GENERICFPCLASSIFIERSELECTION_INCLUDE
+
+//STL
+#include <vector>
+
+//core
+#include "core/basics/StringTools.h"
+
+//vislearning -- feature pool classifier
+#include "vislearning/classifier/fpclassifier/boosting/FPCBoosting.h"
+#include "vislearning/classifier/fpclassifier/randomforest/FPCRandomForests.h"
+#include "vislearning/classifier/fpclassifier/randomforest/FPCDecisionTree.h"
+#include "vislearning/classifier/fpclassifier/logisticregression/FPCSMLR.h"
+#include "vislearning/classifier/fpclassifier/FPCGPHIK.h"
+
+
+
+
+
+
+
+
+namespace OBJREC {
+
+  class GenericFPClassifierSelection
+  {
+    public:
+
+      static FeaturePoolClassifier *selectFPClassifier ( const NICE::Config *conf, std::string classifier_type )
+      {
+        std::vector<std::string> submatches;
+        OBJREC::FeaturePoolClassifier *classifier = NULL;
+
+        ////////////////////////////////////////
+        //                                    //
+        //    all Feature Pool Classifiers    //
+        //                                    //
+        ////////////////////////////////////////
+        if ( classifier_type == "GPHIK" )
+        {
+          classifier = new OBJREC::FPCGPHIK ( conf, "GPHIK" );
+        }      
+        else if ( classifier_type == "random_forest" ) {
+          classifier = new OBJREC::FPCRandomForests ( conf, "RandomForest" );
+        }
+        else if ( classifier_type == "sparse_logistic_regression" )
+        {
+          classifier = new OBJREC::FPCSMLR ( conf, "SparseLogisticRegression" );
+        }
+        else if ( classifier_type == "boost" )
+        {
+          classifier = new OBJREC::FPCBoosting ( conf, "Boost" );
+        }
+        else if ( classifier_type == "decision_tree" )
+        {
+          classifier = new OBJREC::FPCDecisionTree ( conf, "DecisionTree" );
+        } else
+        {
+          fthrow ( NICE::Exception, "Classifier type " << classifier_type << " not (yet) supported." << std::endl <<
+                  "(genericFPClassifierSelection.h contains a list of classifiers to choose from)" );
+        }
+
+        return classifier;
+      }
+
+  };
+
+}
+
+#endif

+ 1 - 0
corefiles.cmake

@@ -470,6 +470,7 @@ SET(nice_vislearning_HDR
 ./classifier/kernelclassifier/LikelihoodFunction.h
 ./classifier/kernelclassifier/KCGPApproxOneClass.h
 ./classifier/genericClassifierSelection.h
+./classifier/GenericFPClassifierSelection.h
 ./matlabAccessHighLevel/ImageNetData.h
 ./image/GenericImageTools.tcc
 ./baselib/FastFilter.tcc

+ 8 - 7
features/fpfeatures/HaarFeature.cpp

@@ -87,9 +87,10 @@ HaarFeature::~HaarFeature()
 
 double HaarFeature::val ( const Example *example ) const
 {
-  const NICE::MultiChannelImageT<long> & img = example->ce->getLChannel ( CachedExample::L_INTEGRALIMAGE );
+  NICE::MultiChannelImageT<long> & img = example->ce->getLChannel ( CachedExample::L_INTEGRALIMAGE );
 
-  //const long *integralImage = img.data[0];
+  long **data = img.getDataPointer();
+  const long *integralImage = data[0];
   int xsize = img.width();
   int ysize = img.height();
 
@@ -127,7 +128,7 @@ double HaarFeature::val ( const Example *example ) const
   assert ( pos1 >= 0 );
   assert ( pos2 >= 0 );
 
-#if 0
+//#if 0
   double value;
   if ( type == HaarFeature::HAARTYPE_HORIZONTAL )
   {
@@ -194,10 +195,10 @@ double HaarFeature::val ( const Example *example ) const
   }
 
   assert ( NICE::isFinite( value ) );
-#else
-  throw("not yet adapted for new MultiChannelImageT!");
-  double value = 0.0;
-#endif
+//#else
+//  throw("not yet adapted for new MultiChannelImageT!");
+//  double value = 0.0;
+//#endif
   return value;
 }