Scale distortion factors to a reasonable amount
Based on detections at driver practice, the distortion factor shouldn't
go above 0.0005 (didn't see any above 0.0002).
Scale factors so that 0.0005 (and anything higher) goes to 1,
so we can intuitively interpret these.
A detection heavily affected by distortion should have a factor of
around 0.1 or greater. Ones closer to the center of the image are
usually less than 0.01.
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
Change-Id: Iacb04c7baa76b58b495832277b1e953aaef7cdaf
diff --git a/y2023/vision/aprilrobotics.cc b/y2023/vision/aprilrobotics.cc
index e694b5e..0102538 100644
--- a/y2023/vision/aprilrobotics.cc
+++ b/y2023/vision/aprilrobotics.cc
@@ -10,6 +10,11 @@
"Minimum decision margin (confidence) for an apriltag detection");
DEFINE_int32(pixel_border, 3,
"Size of image border within which to reject detected corners");
+DEFINE_double(
+ max_expected_distortion, 0.0005,
+ "Maximum expected value for unscaled distortion factors. Will scale "
+ "distortion factors so that this value (and a higher distortion) maps to "
+ "1.0.");
namespace y2023 {
namespace vision {
@@ -153,11 +158,12 @@
}
avg_distance /= corners.size();
- // Normalize avg_distance by dividing by the image size
+ // Normalize avg_distance by dividing by the image size, and then the maximum
+ // expected distortion
double distortion_factor =
avg_distance /
static_cast<double>(image_size_.width * image_size_.height);
- return distortion_factor;
+ return std::min(distortion_factor / FLAGS_max_expected_distortion, 1.0);
}
std::vector<AprilRoboticsDetector::Detection> AprilRoboticsDetector::DetectTags(