Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve default AprilTag config #5896

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,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 @@ -115,9 +115,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 @@ -184,6 +184,7 @@ public boolean equals(Object obj) {

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
Loading