00001 /* 00002 * Copyright (C) 2009 by Ulrich Friedrich Klank <klank@in.tum.de> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 00019 /************************************************************************ 00020 VisLearner.h - Copyright klank 00021 00022 **************************************************************************/ 00023 00024 00025 #ifndef VISLEARNER_H 00026 #define VISLEARNER_H 00027 00028 #include <string> 00029 #include <vector> 00030 #include "SignatureDB.h" 00031 #include "ImageInputSystem.h" 00032 #include "Statistics.h" 00033 #include "RefineAlgorithm.h" 00034 #include "AlgorithmSelector.h" 00035 #include "PerceptionPrimitive.h" 00036 #ifdef BOOST_THREAD 00037 #include "boost/thread.hpp" 00038 #else 00039 #endif 00040 00041 00042 00043 #define XML_NODE_VISLEARNER "VisLearner" 00044 namespace cop 00045 { 00046 typedef int TaskID; 00047 00052 class VisLearner 00053 { 00054 public: 00055 00056 // Constructors/Destructors 00057 // 00058 00062 VisLearner ( XMLTag* tag, SignatureDB& sigDB, ImageInputSystem& imgSys, 00063 #ifdef LOGFILE 00064 LogFile& log, 00065 #endif /*LOGFILE*/ 00066 bool bLearning = true); 00067 00068 00072 virtual ~VisLearner ( ); 00073 private: 00074 VisLearner(); 00075 00076 // Methods 00077 // 00078 public: 00079 XMLTag* Save(); 00085 double RefineObject (Signature& object); 00086 00087 00096 SignatureLocations_t RefineObject (PossibleLocations_t* lastKnownPoses, PerceptionPrimitive &visPrim, int &numOfObjects); 00105 SignatureLocations_t ProoveObject(PossibleLocations_t* lastKnownPoses, PerceptionPrimitive &visPrim, int &numOfObjects); 00106 00107 void AddAlgorithm(Algorithm<Descriptor*>*); 00108 void AddAlgorithm(Algorithm<ImprovedPose >*); 00109 00114 Signature* GetObjectSignature (int index ); 00115 00116 00117 void threadfunc(); 00118 00119 const AlgorithmSelector<Descriptor* >& GetRefineAlgorithmSelection(){return m_refinements;} 00120 const AlgorithmSelector<ImprovedPose>& GetProoveAlgorithmSelection(){return m_checks;} 00121 00122 00123 private: 00124 00125 // Private attributes 00126 // 00127 SignatureDB& m_signatureDB; 00128 ImageInputSystem& m_imageSys; 00129 Statistics m_stats; 00130 00131 00132 std::vector<std::pair<TaskID, Signature*> > m_taskList; 00133 AlgorithmSelector<Descriptor* > m_refinements; 00134 AlgorithmSelector<ImprovedPose> m_checks; 00135 #ifdef BOOST_THREAD 00136 boost::thread* m_learningThread; 00137 #else 00138 #endif 00139 static bool s_Learning; 00140 static bool s_Running; 00141 private: 00142 VisLearner& operator=(VisLearner&){throw "Error";} 00143 00144 }; 00145 } 00146 #endif // VISLEARNER_H