Skip to content

Commit

Permalink
Merge pull request #93 from akshayprsd/add_configurable_max_hamming_d…
Browse files Browse the repository at this point in the history
…istance

Add configurable max_hamming_distance for the AprilTag Detector
  • Loading branch information
wxmerkt committed Apr 7, 2021
2 parents ee868d3 + 01aa886 commit acfce85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions apriltag_ros/config/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ tag_decimate: 1.0 # default: 1.0
tag_blur: 0.0 # default: 0.0
tag_refine_edges: 1 # default: 1
tag_debug: 0 # default: 0
max_hamming_dist: 2 # default: 2 (Tunable parameter with 2 being a good choice - values >=3 consume large amounts of memory. Choose the largest value possible.)
# Other parameters
publish_tf: true # default: false
3 changes: 3 additions & 0 deletions apriltag_ros/include/apriltag_ros/common_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ class TagDetector
double blur_;
int refine_edges_;
int debug_;
int max_hamming_distance_ = 2; // Tunable, but really, 2 is a good choice. Values of >=3
// consume prohibitively large amounts of memory, and otherwise
// you want the largest value possible.

// AprilTag 2 objects
apriltag_family_t *tf_;
Expand Down
3 changes: 2 additions & 1 deletion apriltag_ros/src/common_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ TagDetector::TagDetector(ros::NodeHandle pnh) :
blur_(getAprilTagOption<double>(pnh, "tag_blur", 0.0)),
refine_edges_(getAprilTagOption<int>(pnh, "tag_refine_edges", 1)),
debug_(getAprilTagOption<int>(pnh, "tag_debug", 0)),
max_hamming_distance_(getAprilTagOption<int>(pnh, "max_hamming_dist", 2)),
publish_tf_(getAprilTagOption<bool>(pnh, "publish_tf", false))
{
// Parse standalone tag descriptions specified by user (stored on ROS
Expand Down Expand Up @@ -146,7 +147,7 @@ TagDetector::TagDetector(ros::NodeHandle pnh) :

// Create the AprilTag 2 detector
td_ = apriltag_detector_create();
apriltag_detector_add_family(td_, tf_);
apriltag_detector_add_family_bits(td_, tf_, max_hamming_distance_);
td_->quad_decimate = (float)decimate_;
td_->quad_sigma = (float)blur_;
td_->nthreads = threads_;
Expand Down

0 comments on commit acfce85

Please sign in to comment.