std::string Detector::query(Scene &scene) { static int i = 0; if (detector_vis_) { std::stringstream ss; std::string s; ss << i; s = ss.str(); detector_vis_->addCloud(scene.id + "_test_" + s, scene.cloud); i++; } cout << "detector testing " << scene.id << endl; Entry e; e.cloud = scene.cloud; timer.start(); e.keypoints = computeKeypoints(e.cloud); timer.stop(KEYPOINTS_TESTING); timer.start(); e.features = obtainFeatures(scene, e.keypoints, true); timer.stop(COMPUTE_FEATURES_TESTING); e.id = scene.id; StopWatch s; std::vector<std::string> all_ids; for (std::map<std::string, Entry>::iterator db_it = database_->begin(); db_it != database_->end(); db_it++) { all_ids.push_back((*db_it).first); } std::vector<std::string> current_ids = all_ids; for (size_t i = 0; i < proposers_.size(); i++) { Proposer::Ptr current_proposer = proposers_[i]; current_proposer->setDatabase(database_); current_proposer->getProposed(num_registration, e, current_ids, current_ids); cout << "Proposed after stage " << i << ":"; for (size_t i = 0; i < current_ids.size(); i++) { cout << current_ids[i] << " "; } cout << endl; } return current_ids[0]; }
// ###################################################################### VisualObject::VisualObject(const std::string& name, const std::string& imagefname, const Image< PixRGB<byte> >& image, const Point2D<int>& salpt, const std::vector<float>& preattfeatures, const std::vector< rutz::shared_ptr<Keypoint> >& keypoints, const bool useColor, bool computeKP) : itsName(name), itsImageFname(imagefname), itsImage(image), itsKeypoints(keypoints), itsSalPoint(salpt), itsFeatures(preattfeatures), itsIsSorted(false), itsUseColor(useColor),itsImageLoaded(true) { itsObjectSize = image.getDims(); if(computeKP) computeKeypoints(); }
/* Trains a single model */ void Detector::train(Scene &scene) { srand(0); PointCloud<PointNormal>::Ptr keypoints = computeKeypoints(scene.cloud); if (detector_vis_) { detector_vis_->addCloud(scene.id + "keypoints", keypoints); detector_vis_->addCloud(scene.id + "original", scene.cloud); } PointCloud<Signature>::Ptr features = obtainFeatures(scene, keypoints, false, true); Entry e; e.cloud = scene.cloud; e.keypoints = keypoints; e.features = features; e.tree = KdTreeFLANN<Signature>::Ptr(new KdTreeFLANN<Signature>()); e.tree->setInputCloud(e.features); e.id = scene.id; (*database_)[scene.id] = e; }