Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef BLORTTRACKER_H
00044 #define BLORTTRACKER_H
00045
00046 #include <opencv2/core/core.hpp>
00047 #include <boost/foreach.hpp>
00048
00049 namespace blort_ros
00050 {
00051 enum tracker_mode
00052 {
00053 TRACKER_RECOVERY_MODE,
00054 TRACKER_TRACKING_MODE,
00055 TRACKER_LOCKED_MODE
00056 };
00057
00058 enum tracker_confidence
00059 {
00060 TRACKER_CONF_GOOD,
00061 TRACKER_CONF_FAIR,
00062 TRACKER_CONF_LOST
00063 };
00064
00065 class TrackerInterface
00066 {
00067 protected:
00068 std::map<std::string, tracker_mode> current_modes;
00069 std::map<std::string, tracker_confidence> current_confs;
00070 cv::Mat last_image;
00071
00072 public:
00073 TrackerInterface()
00074 {
00075 }
00076 virtual void track() = 0;
00077 virtual void recovery() = 0;
00078 void process(cv::Mat img)
00079 {
00080 last_image = img;
00081 tracker_mode current_mode = TRACKER_RECOVERY_MODE;
00082 typedef std::pair<std::string, blort_ros::tracker_mode> NameModePair_t;
00083 BOOST_FOREACH(NameModePair_t item, current_modes)
00084 {
00085 if(item.second != current_mode)
00086 {
00087
00088 current_mode = item.second;
00089 break;
00090 }
00091 }
00092 switch(current_mode)
00093 {
00094 case TRACKER_RECOVERY_MODE:
00095 recovery();
00096 break;
00097 case TRACKER_TRACKING_MODE:
00098 track();
00099 break;
00100 case TRACKER_LOCKED_MODE:
00101 track();
00102 break;
00103 }
00104 }
00105
00106 virtual void switchToTracking(std::string id)
00107 {
00108 current_confs[id] = TRACKER_CONF_FAIR;
00109 current_modes[id] = TRACKER_TRACKING_MODE;
00110 }
00111
00112 virtual void switchToRecovery(std::string id)
00113 {
00114 current_confs[id] = TRACKER_CONF_LOST;
00115 current_modes[id] = TRACKER_RECOVERY_MODE;
00116 }
00117
00118 virtual void reset(std::string id){ switchToRecovery(id); }
00119 tracker_mode getMode(std::string id){ return current_modes[id]; }
00120 tracker_confidence getConfidence(std::string id){ return current_confs[id]; }
00121 };
00122 }
00123
00124 #endif // BLORTTRACKER_H