#include "FeatureDetector.h" #include "landmarkUtils.h" #include #include using namespace cv; using namespace std; using namespace gtsam; FeatureDetector::FeatureDetector(const char* colorDescFile) { readLandMarkColors(colorDescFile, vColors_); } int FeatureDetector::findColorId(const RGBColor& color) { for (size_t i = 0; i FeatureDetector::detect(const cv::Mat& image) { vFeatures_.clear(); RGBColor BLACK(0,0,0); map numPixels; // for (int y = 0; y(y,x) == BLACK) continue; RGBColor color = image.at(y,x); int t = color[2]; color[2] = color[0]; color[0] = t; int colorId = findColorId(color); if (colorId == -1) continue; map::iterator it = numPixels.find(colorId) ; if (it == numPixels.end()) { numPixels[colorId] = 1; vFeatures_.push_back(Feature2D(colorId, Point2(x,y))); } else { size_t k = 0; for (; k& FeatureDetector::read(const char* filename) { ifstream file(filename); int numFeatures; file >> numFeatures ; vFeatures_.clear(); for (size_t i = 0; i < numFeatures; i++) { int id; double x, y; file >> id >> x >> y; vFeatures_.push_back(Feature2D(id, Point2(x, y))); } file.close(); return vFeatures_; }