Skip to content

Commit

Permalink
[apriltag] Improve AprilTagDetector default config (#6847)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 authored Jul 19, 2024
1 parent 602325d commit 8d857cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public boolean equals(Object obj) {
/** Quad threshold parameters. */
@SuppressWarnings("MemberName")
public static class QuadThresholdParameters {
/** Threshold used to reject quads containing too few pixels. Default is 5 pixels. */
public int minClusterPixels = 5;
/** Threshold used to reject quads containing too few pixels. Default is 300 pixels. */
public int minClusterPixels = 300;

/**
* How many corner candidates to consider when segmenting a group of pixels into a quad. Default
Expand All @@ -124,9 +124,9 @@ public static class QuadThresholdParameters {
/**
* Critical angle, in radians. The detector will reject quads where pairs of edges have angles
* that are close to straight or close to 180 degrees. Zero means that no quads are rejected.
* Default is 10 degrees.
* Default is 45 degrees.
*/
public double criticalAngle = 10 * Math.PI / 180.0;
public double criticalAngle = 45 * Math.PI / 180.0;

/**
* When fitting lines to the contours, the maximum mean squared error allowed. This is useful in
Expand Down Expand Up @@ -203,6 +203,7 @@ public boolean equals(Object obj) {
/** Constructs an AprilTagDetector. */
public AprilTagDetector() {
m_native = AprilTagJNI.createDetector();
setQuadThresholdParameters(new QuadThresholdParameters());
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion apriltag/src/main/native/cpp/AprilTagDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ void AprilTagDetector::Results::Destroy() {
}
}

AprilTagDetector::AprilTagDetector() : m_impl{apriltag_detector_create()} {}
AprilTagDetector::AprilTagDetector() : m_impl{apriltag_detector_create()} {
SetQuadThresholdParameters({});
}

AprilTagDetector& AprilTagDetector::operator=(AprilTagDetector&& rhs) {
Destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class WPILIB_DLLEXPORT AprilTagDetector {
bool operator==(const QuadThresholdParameters&) const = default;

/**
* Threshold used to reject quads containing too few pixels. Default is 5
* Threshold used to reject quads containing too few pixels. Default is 300
* pixels.
*/
int minClusterPixels = 5;
int minClusterPixels = 300;

/**
* How many corner candidates to consider when segmenting a group of pixels
Expand All @@ -97,9 +97,9 @@ class WPILIB_DLLEXPORT AprilTagDetector {
/**
* Critical angle. The detector will reject quads where pairs of edges have
* angles that are close to straight or close to 180 degrees. Zero means
* that no quads are rejected. Default is 10 degrees.
* that no quads are rejected. Default is 45 degrees.
*/
units::radian_t criticalAngle = 10_deg;
units::radian_t criticalAngle = 45_deg;

/**
* When fitting lines to the contours, the maximum mean squared error
Expand Down

0 comments on commit 8d857cd

Please sign in to comment.