/* * Create a new person from the provided stamped pose and point cloud, and insert them into the map. */ Person& PersonDetector::create_person(const geometry_msgs::Pose& pose, const sensor_msgs::PointCloud2& cloud) { // Make a new person with the trivial person classifier, for now, and then give them an initial pose. Person lifeform(_current_uid++); lifeform.push_pose(pose); // boost::shared_ptr<PersonClassifier> classifier(new ShirtColorPersonClassifier(cloud, 30.0)); boost::shared_ptr<PersonClassifier> classifier(new TrivialPersonClassifier); // Then insert them. tracked()[lifeform.uid()] = lifeform; classifiers()[lifeform.uid()] = classifier; // Return a reference to the person in the map. return tracked()[lifeform.uid()]; }
void learn(const database<double, bool> &data, const ublas::vector<double> &sample_weights){ ASSERT(data.patterns.size2() == data.targets.size(), " "); ASSERT(is_equal(sum(sample_weights), 1.0, 1e-2), " "); std::vector<tsf_classifier> classifiers(data.patterns.size1()); for (size_t i = 0; i < classifiers.size(); ++i){ classifiers[i] = _tsfc_prototype.clone(); classifiers[i].feature_index(i); classifiers[i].learn(data, sample_weights); } auto min_it = std::min_element(classifiers.begin(), classifiers.end(), [&](const tsf_classifier &lhs, const tsf_classifier &rhs){ return lhs.error() < rhs.error(); }); _best_classifier = classifiers[min_it - classifiers.begin()]; }
/* * Attempt to find a classifier by UID. Returns a reference to the classifier if found, or an empty optional otherwise. */ boost::optional<PersonClassifier&> PersonDetector::classifier_by_id(unsigned int uid) { if(classifiers().count(uid) >= 1) return *classifiers()[uid]; return boost::none; }