From 22187a974721863327fa331c9fd01688db1bd414 Mon Sep 17 00:00:00 2001 From: Aidan Olsen Date: Wed, 17 Jan 2024 17:09:21 -0700 Subject: [PATCH] [WIP] Setup ImageAnalysisDelegate --- src/modules/imaging/analysis.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/modules/imaging/analysis.py diff --git a/src/modules/imaging/analysis.py b/src/modules/imaging/analysis.py new file mode 100644 index 0000000..45e3f15 --- /dev/null +++ b/src/modules/imaging/analysis.py @@ -0,0 +1,26 @@ +from typing import Optional + +from deps.labeller.benchmarks.detector import LandingPadDetector, BoundingBox +from .camera import CameraProvider + + +class ImageAnalysisDelegate: + """ + Responsible for capturing pictures regularly, detecting any landing pads in + those pictures and then providing the most recent estimate of the landing + pad location from the camera's perspective. + + TODO: geolocate the landing pad using the drone's location. + """ + + def __init__(self, camera_provider: CameraProvider, detector: LandingPadDetector): + self.camera_provider = camera_provider + self.detector = detector + + def locate_landing_pad(self) -> Optional[BoundingBox]: + """ + Capture an image and then locate a landing pad, if any, from that + image. Returns None if no landing pad was found. + """ + image = self.camera_provider.capture() + return self.detector.predict(image)