Put blob detection results in a struct
Passing around 5 variables got really clunky.
Signed-off-by: Milind Upadhyay <milind.upadhyay@gmail.com>
Change-Id: I27b073635377c344aa02b01a094169ef90aff56e
diff --git a/y2022/vision/blob_detector.h b/y2022/vision/blob_detector.h
index f8a4ab4..4077e2c 100644
--- a/y2022/vision/blob_detector.h
+++ b/y2022/vision/blob_detector.h
@@ -16,7 +16,15 @@
size_t num_points;
};
+ struct BlobResult {
+ cv::Mat binarized_image;
+ std::vector<std::vector<cv::Point>> filtered_blobs, unfiltered_blobs;
+ std::vector<BlobStats> blob_stats;
+ cv::Point centroid;
+ };
+
BlobDetector() {}
+
// Given an image, threshold it to find "green" pixels
// Input: Color image
// Output: Grayscale (binarized) image with green pixels set to 255
@@ -44,11 +52,7 @@
const std::vector<std::vector<cv::Point>> &unfiltered_blobs,
const std::vector<BlobStats> &blob_stats, cv::Point centroid);
- static void ExtractBlobs(
- cv::Mat rgb_image, cv::Mat &binarized_image,
- std::vector<std::vector<cv::Point>> &filtered_blobs,
- std::vector<std::vector<cv::Point>> &unfiltered_blobs,
- std::vector<BlobStats> &blob_stats, cv::Point ¢roid);
+ static void ExtractBlobs(cv::Mat rgb_image, BlobResult *blob_result);
};
} // namespace vision
} // namespace y2022