42 #include <jsk_recognition_msgs/ClassificationResult.h> 48 DiagnosticNodelet::onInit();
53 srv_ = boost::make_shared<dynamic_reconfigure::Server<Config> >(*pnh_);
54 dynamic_reconfigure::Server<Config>::CallbackType
f =
57 pub_class_ = advertise<jsk_recognition_msgs::ClassificationResult>(*
pnh_,
"output", 1);
65 std::vector<std::string>
labels;
66 pnh_->param(
"label_names", labels, std::vector<std::string>());
73 for (
size_t i = 0; i < labels.size(); ++i) {
74 std::string name =
"histograms/" + labels[i];
76 std::vector<float> hist;
77 pnh_->param(name, hist, std::vector<float>());
127 std::vector<double>& distances) {
140 jsk_recognition_msgs::ClassificationResult
result;
141 result.header = histogram->header;
145 std::vector<double> distances;
148 double max_prob = 0.0;
150 for (
size_t i = 0; i < distances.size(); ++i) {
151 double prob = distances[i];
152 result.probabilities.push_back(prob);
153 if (prob > max_prob) {
160 result.labels.push_back(label);
162 result.label_proba.push_back(max_prob);
164 result.labels.push_back(-1);
165 result.label_names.push_back(std::string());
166 result.label_proba.push_back(0.0);
176 jsk_recognition_msgs::ClassificationResult
result;
177 result.header = histograms->header;
181 for (
size_t i = 0; i < histograms->histograms.size(); ++i) {
182 std::vector<double> distances;
185 double max_prob = 0.0;
187 for (
size_t i = 0; i < distances.size(); ++i) {
188 double prob = distances[i];
189 result.probabilities.push_back(prob);
190 if (prob > max_prob) {
197 result.labels.push_back(label);
199 result.label_proba.push_back(max_prob);
201 result.labels.push_back(-1);
202 result.label_names.push_back(std::string());
203 result.label_proba.push_back(0.0);
#define NODELET_INFO_STREAM(...)
virtual void configCallback(Config &config, uint32_t level)
void publish(const boost::shared_ptr< M > &message) const
bool compareHistogram(const std::vector< float > &input, const std::vector< float > &reference, const ComparePolicy policy, double &distance)
ros::Subscriber sub_hist_
double detection_threshold_
std::vector< std::string > label_names_
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
virtual bool loadReference()
std::string classifier_name_
virtual void unsubscribe()
virtual void features(const jsk_recognition_msgs::ColorHistogramArray::ConstPtr &histograms)
#define NODELET_ERROR_STREAM(...)
ColorHistogramClassifierConfig Config
virtual void feature(const jsk_recognition_msgs::ColorHistogram::ConstPtr &histogram)
ros::Publisher pub_class_
jsk_recognition_utils::ComparePolicy compare_policy_
std::vector< std::vector< float > > reference_histograms_
ros::Subscriber sub_hists_
#define NODELET_FATAL_STREAM(...)
PLUGINLIB_EXPORT_CLASS(jsk_pcl_ros::ColorHistogramClassifier, nodelet::Nodelet)
virtual void computeDistance(const std::vector< float > &histogram, std::vector< double > &distance)