00001
00002
00003 #ifndef HPM_EXPORT_HPP
00004 #define HPM_EXPORT_HPP
00005
00006 #include <vector>
00007 #include <map>
00008 #include <utility>
00009
00010 #include "fdetect/DetectionResult.hpp"
00011 #include "gfm/MatchingResult.hpp"
00012 #include "hpm/CompatStructures.hpp"
00013
00014 namespace jafar {
00015 namespace hpm {
00016
00019
00023 class HarrisPoint {
00024 public:
00025
00027 typedef std::vector<HarrisPoint> Vec;
00028
00029 static const unsigned int NO_ID;
00030
00032 unsigned int id;
00033
00035 float u;
00037 float v;
00038
00040 float lambdaHigh;
00042 float lambdaLow;
00043
00044 HarrisPoint();
00045 virtual ~HarrisPoint();
00046
00047 virtual void clear();
00048 };
00049
00052 class StereoHarrisPoint : public HarrisPoint {
00053 public:
00054
00056 typedef std::vector<StereoHarrisPoint> Vec;
00057
00058 static const int NO_STEREO_INDEX;
00059
00063 int stereoIndex;
00064
00065 StereoHarrisPoint();
00066 virtual ~StereoHarrisPoint();
00067
00068 virtual void clear();
00069
00070 };
00071
00072
00073 #ifndef SWIG
00074 std::ostream& operator <<(std::ostream& s, const HarrisPoint& p_);
00075 std::ostream& operator <<(std::ostream& s, const StereoHarrisPoint& p_);
00076 #endif
00077
00078
00081 struct HpmGroup {
00082 HpmGroup();
00083 HarrisPoint points[LOCAL_GROUP_MEMBER_NUM];
00086 int match_index;
00087 };
00088
00090 typedef std::vector<HarrisPoint> vecHarrisPoints;
00091
00093 typedef std::vector<StereoHarrisPoint> vecStereoHarrisPoints;
00094
00096 typedef std::pair<std::size_t, std::size_t> match;
00097
00098
00100 typedef std::vector<match> vecMatches;
00101
00103 typedef std::map<std::size_t, std::size_t> mapMatches;
00104
00106 typedef std::vector<HpmGroup> vecGroups;
00107
00110 template<class Point>
00111 void exportHarrisPoints(const jafar::fdetect::DetectionResult & saveResult,
00112 std::vector<Point>& points)
00113 {
00114 points.resize(saveResult.countInterestFeatures());
00115 int i = 0;
00116 for(fdetect::vInterestFeatures_cit it = saveResult.beginFeatures();
00117 it != saveResult.endFeatures(); it++, i++) {
00118 points[i].clear();
00119 points[i].u = (*it)->u();
00120 points[i].v = (*it)->v();
00121 points[i].lambdaHigh = (*it)->quality();
00122 points[i].lambdaLow = (*it)->quality();
00123 }
00124 };
00125
00126
00129 void exportMatches(const jafar::gfm::MatchingResult& gfm_result,
00130 jafar::hpm::vecMatches& matches);
00131
00134 void exportMatches(const jafar::gfm::MatchingResult& gfm_result,
00135 mapMatches& matches);
00136
00140 void exportStereoMatches(vecMatches const& matches,
00141 vecStereoHarrisPoints & vecPointsLeft,
00142 vecStereoHarrisPoints & vecPointsRight);
00143
00147 template<class PointRef, class PointMatch>
00148 unsigned int propagateId(vecMatches const& matches,
00149 std::vector<PointRef> const& vecPointsRef,
00150 std::vector<PointMatch> & vecPointsMatch)
00151 {
00152 unsigned int cpt = 0;
00153 for (vecMatches::const_iterator it = matches.begin() ; it!=matches.end() ; it++) {
00154 if (vecPointsRef.at(it->first).id != HarrisPoint::NO_ID) {
00155 vecPointsMatch.at(it->second).id = vecPointsRef.at(it->first).id;
00156 cpt++;
00157 }
00158 }
00159 return cpt;
00160 };
00161
00165 template<class PointRef, class PointMatch>
00166 unsigned int backPropagateId(mapMatches const& matches,
00167 std::vector<PointRef> & vecPointsRef,
00168 std::vector<PointMatch> const& vecPointsMatch)
00169 {
00170 unsigned int cpt = 0;
00171 for (mapMatches::const_iterator it = matches.begin() ; it!=matches.end() ; it++) {
00172 if (vecPointsMatch.at(it->second).id != HarrisPoint::NO_ID) {
00173 vecPointsRef.at(it->first).id = vecPointsMatch.at(it->second).id;
00174 cpt++;
00175 }
00176 }
00177 return cpt;
00178 };
00179
00182 }
00183 }
00184
00185 #endif // HPM_EXPORT_HARRIS_HPP