Skip to content

Commit

Permalink
Merge pull request #9 from iory/add-parameter-hog
Browse files Browse the repository at this point in the history
Add parameter to people_detector
  • Loading branch information
k-okada committed May 31, 2016
2 parents 2dc3d7a + d16edbe commit 8464aff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cfg/PeopleDetect.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ from dynamic_reconfigure.parameter_generator_catkin import *
gen = ParameterGenerator()
gen.add("use_camera_info", bool_t, 0, "Indicates that the camera_info topic should be subscribed to to get the default input_frame_id. Otherwise the frame from the image message will be used.", True)

gen.add("hit_threshold", double_t, 150, "Threshold for the distance between features and SVM classifying plane.", 0, 0, 10)
gen.add("win_stride", int_t, 8, "Window stride. It must be a multiple of block stride.", 8, 1, 100)
gen.add("padding", int_t, 32, "Mock parameter to keep the CPU interface compatibility. It must be (0,0).", 32, 0, 128)
gen.add("scale0", double_t, 1.05, "Coefficient of the detection window increase.", 1.05, 1.0, 100.0)
gen.add("group_threshold", int_t, 2, "Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping.", 2, 0, 100)

exit(gen.generate(PACKAGE, "people_detect", "PeopleDetect"))
13 changes: 12 additions & 1 deletion src/nodelet/people_detect_nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,20 @@ class PeopleDetectNodelet : public opencv_apps::Nodelet

cv::HOGDescriptor hog_;

double hit_threshold_;
int win_stride_;
int padding_;
double scale0_;
int group_threshold_;

void reconfigureCallback(people_detect::PeopleDetectConfig &new_config, uint32_t level)
{
config_ = new_config;
hit_threshold_ = config_.hit_threshold;
win_stride_ = config_.win_stride;
padding_ = config_.padding;
scale0_ = config_.scale0;
group_threshold_ = config_.group_threshold;
}

const std::string &frameWithDefault(const std::string &frame, const std::string &image_frame)
Expand Down Expand Up @@ -122,7 +133,7 @@ class PeopleDetectNodelet : public opencv_apps::Nodelet
// run the detector with default parameters. to get a higher hit-rate
// (and more false alarms, respectively), decrease the hitThreshold and
// groupThreshold (set groupThreshold to 0 to turn off the grouping completely).
hog_.detectMultiScale(frame, found, 0, cv::Size(8,8), cv::Size(32,32), 1.05, 2);
hog_.detectMultiScale(frame, found, hit_threshold_, cv::Size(win_stride_, win_stride_), cv::Size(padding_, padding_), scale0_, group_threshold_);
t = (double)cv::getTickCount() - t;
NODELET_INFO("tdetection time = %gms", t*1000./cv::getTickFrequency());
size_t i, j;
Expand Down

0 comments on commit 8464aff

Please sign in to comment.