blob: 3da3d4b73f68764860147983e9ec7c645d59dd8b [file] [log] [blame]
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -08001#ifndef Y2022_BLOB_DETECTOR_H_
2#define Y2022_BLOB_DETECTOR_H_
3
4#include <opencv2/imgproc.hpp>
5
6namespace y2022 {
7namespace vision {
8
9class BlobDetector {
10 public:
11 BlobDetector() {}
12 // Given an image, threshold it to find "green" pixels
13 // Input: Color image
14 // Output: Grayscale (binarized) image with green pixels set to 255
15 static cv::Mat ThresholdImage(cv::Mat rgb_image);
16
17 // Given binary image, extract blobs
18 static std::vector<std::vector<cv::Point>> FindBlobs(cv::Mat threshold_image);
19
20 // Filter blobs to get rid of noise, too large items, etc.
21 static std::vector<std::vector<cv::Point>> FilterBlobs(
22 std::vector<std::vector<cv::Point>> blobs);
23
24 // Draw Blobs on image
25 // Optionally draw all blobs and filtered blobs
26 static void DrawBlobs(cv::Mat view_image,
27 std::vector<std::vector<cv::Point>> filtered_blobs,
28 std::vector<std::vector<cv::Point>> unfiltered_blobs);
29
30 // Extract stats for each blob
31 static std::vector<std::vector<cv::Point>> ComputeStats(
32 std::vector<std::vector<cv::Point>>);
33
34 static void ExtractBlobs(
35 cv::Mat rgb_image, cv::Mat binarized_image, cv::Mat blob_image,
36 std::vector<std::vector<cv::Point>> &filtered_blobs,
37 std::vector<std::vector<cv::Point>> &unfiltered_blobs,
38 std::vector<std::vector<cv::Point>> &blob_stats);
39};
40} // namespace vision
41} // namespace y2022
42
43#endif // Y2022_BLOB_DETECTOR_H_