Filter out blobs with too many points
Filters out people's hands in the earliest stage, preventing that from
triggering the vision status led.
Signed-off-by: Milind Upadhyay <milind.upadhyay@gmail.com>
Change-Id: Ib02896c780d433dd44dc0dbfac666df05da0cf4b
diff --git a/y2022/vision/blob_detector.cc b/y2022/vision/blob_detector.cc
index 2f90513..a091298 100644
--- a/y2022/vision/blob_detector.cc
+++ b/y2022/vision/blob_detector.cc
@@ -118,13 +118,15 @@
constexpr double kAspectRatioThreshold = 2.0;
constexpr double kMinArea = 10;
constexpr size_t kMinNumPoints = 2;
+ constexpr size_t kMaxNumPoints = 50;
// Remove all blobs that are at the bottom of the image, have a different
// aspect ratio than the tape, or have too little area or points.
if ((std::abs(1.0 - kTapeAspectRatio / stats_it->aspect_ratio) <
kAspectRatioThreshold) &&
(stats_it->area >= kMinArea) &&
- (stats_it->num_points >= kMinNumPoints)) {
+ (stats_it->num_points >= kMinNumPoints) &&
+ (stats_it->num_points <= kMaxNumPoints)) {
filtered_blobs.push_back(*blob_it);
filtered_stats.push_back(*stats_it);
}