Moving camera calib files to use camera#

Modifying intrinsics_calibration to handle and use this new format

Changing numbering to match /dev/video#, so that camera on /dev/video0
is publishing on /camera0 for example

Added a utility function to get camera number from channel, and a test to
go with it

Cleaned up some of the logging to use percentages instead of fractions /
decimals

Change-Id: I764d59ca7d9089a37d010272879ce55aae5dbd95
Signed-off-by: Jim Ostrowski <yimmy13@gmail.com>
diff --git a/frc971/vision/vision_util_lib.cc b/frc971/vision/vision_util_lib.cc
index b65e883..bfd6209 100644
--- a/frc971/vision/vision_util_lib.cc
+++ b/frc971/vision/vision_util_lib.cc
@@ -43,4 +43,19 @@
   return result;
 }
 
+std::optional<uint16_t> CameraNumberFromChannel(std::string camera_channel) {
+  if (camera_channel.find("/camera") == std::string::npos) {
+    return std::nullopt;
+  }
+  // If the string doesn't end in /camera#, return nullopt
+  uint16_t cam_len = std::string("/camera").length();
+  if (camera_channel.length() != camera_channel.find("/camera") + cam_len + 1) {
+    return std::nullopt;
+  }
+
+  uint16_t camera_number = std::stoi(
+      camera_channel.substr(camera_channel.find("/camera") + cam_len, 1));
+  return camera_number;
+}
+
 }  // namespace frc971::vision