mirror of
https://github.com/kristoferssolo/Traffic-Light-Detector.git
synced 2026-03-22 00:36:22 +00:00
Fixed type hints
This commit is contained in:
@@ -30,7 +30,7 @@ class TrafficLightDetector:
|
|||||||
self.green = Color("GREEN", self.GREEN, self.GREEN_LOWER, self.GREEN_UPPER, hsv, minDist=30, param2=5)
|
self.green = Color("GREEN", self.GREEN, self.GREEN_LOWER, self.GREEN_UPPER, hsv, minDist=30, param2=5)
|
||||||
self.colors = [self.red, self.yellow, self.green]
|
self.colors = [self.red, self.yellow, self.green]
|
||||||
|
|
||||||
def _draw_circle(self):
|
def _draw_circle(self) -> None:
|
||||||
try:
|
try:
|
||||||
for color in self.colors:
|
for color in self.colors:
|
||||||
if color.circle is not None:
|
if color.circle is not None:
|
||||||
@@ -50,5 +50,6 @@ class TrafficLightDetector:
|
|||||||
cv2.circle(self.image_copy, (i[0], i[1]), i[2] + 10, color.color, 2)
|
cv2.circle(self.image_copy, (i[0], i[1]), i[2] + 10, color.color, 2)
|
||||||
cv2.circle(color.mask, (i[0], i[1]), i[2] + 30, (255, 255, 255), 2)
|
cv2.circle(color.mask, (i[0], i[1]), i[2] + 30, (255, 255, 255), 2)
|
||||||
cv2.putText(self.image_copy, color.name, (i[0], i[1]), self.FONT, 1, color.color, 2, cv2.LINE_AA)
|
cv2.putText(self.image_copy, color.name, (i[0], i[1]), self.FONT, 1, color.color, 2, cv2.LINE_AA)
|
||||||
|
logger.debug(color.name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logger.warning("Image/frame was not specified")
|
logger.warning("Image/frame was not specified")
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ from TrafficLightDetector.traffic_light_detector import TrafficLightDetector
|
|||||||
|
|
||||||
class TrafficLightDetectorImages(TrafficLightDetector):
|
class TrafficLightDetectorImages(TrafficLightDetector):
|
||||||
|
|
||||||
def __init__(self, path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
self.path = path
|
self.path = path
|
||||||
self.image = cv2.imread(str(path))
|
image = cv2.imread(str(path))
|
||||||
super().__init__(self.image)
|
self._set_image(image)
|
||||||
|
|
||||||
def _save_image(self) -> None:
|
def _save_image(self) -> None:
|
||||||
cv2.imwrite(str(IMAGES_OUT_PATH.joinpath(self.path.name)), self.image_copy)
|
cv2.imwrite(str(IMAGES_OUT_PATH.joinpath(self.path.name)), self.image_copy)
|
||||||
|
|
||||||
def draw(self) -> None:
|
def draw(self) -> None:
|
||||||
self._draw_circle(self.image)
|
self._draw_circle()
|
||||||
self._save_image()
|
self._save_image()
|
||||||
|
|||||||
Reference in New Issue
Block a user