Use a solver for hub estimation

Uses ceres to estimate the rotation and distance
from the hub to the camera.
Ready for reviewing

Signed-off-by: Milind Upadhyay <milind.upadhyay@gmail.com>
Change-Id: Idd4fb3334146a0587c713887626cb0abe43cdd4e
diff --git a/y2022/vision/blob_detector.h b/y2022/vision/blob_detector.h
index d263d32..d0a2b85 100644
--- a/y2022/vision/blob_detector.h
+++ b/y2022/vision/blob_detector.h
@@ -20,6 +20,8 @@
     cv::Mat binarized_image;
     std::vector<std::vector<cv::Point>> filtered_blobs, unfiltered_blobs;
     std::vector<BlobStats> blob_stats;
+    // In sorted order from left to right on the circle
+    std::vector<cv::Point> filtered_centroids;
     cv::Point centroid;
   };
 
@@ -35,22 +37,16 @@
 
   // Extract stats for each blob
   static std::vector<BlobStats> ComputeStats(
-      std::vector<std::vector<cv::Point>> blobs);
+      const std::vector<std::vector<cv::Point>> &blobs);
 
   // Filter blobs to get rid of noise, too small/large items, and blobs that
-  // aren't in a circle. Returns a pair of filtered blobs and the average
-  // of their centroids.
-  static std::pair<std::vector<std::vector<cv::Point>>, cv::Point> FilterBlobs(
-      std::vector<std::vector<cv::Point>> blobs,
-      std::vector<BlobStats> blob_stats);
+  // aren't in a circle. Finds the filtered blobs, centroids, and the absolute
+  // centroid.
+  static void FilterBlobs(BlobResult *blob_result);
 
   // Draw Blobs on image
   // Optionally draw all blobs and filtered blobs
-  static void DrawBlobs(
-      cv::Mat view_image,
-      const std::vector<std::vector<cv::Point>> &filtered_blobs,
-      const std::vector<std::vector<cv::Point>> &unfiltered_blobs,
-      const std::vector<BlobStats> &blob_stats, cv::Point centroid);
+  static void DrawBlobs(const BlobResult &blob_result, cv::Mat view_image);
 
   static void ExtractBlobs(cv::Mat bgr_image, BlobResult *blob_result);
 };