Skip to content

Commit

Permalink
draw bboxes and update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
GearBoxFox committed Feb 5, 2024
1 parent 8f45de5 commit 5e09a31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions py/src/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from config.Config import ConfigStore, LocalConfig, RemoteConfig
from config.ConfigSource import FileConfigSource, NTConfigSource
from pipeline.Capture import CVCapture
from pipeline.Detector import Detector, draw_bbox
from output.StreamServer import StreamServer

import time
Expand All @@ -9,12 +11,19 @@

capture = CVCapture()
stream_server = StreamServer()
file_config = FileConfigSource()
remote_config = NTConfigSource()

file_config.update(config)

detector = Detector(config)
stream_server.start(config)

frame_count = 0
last_print = 0
while True:
remote_config.update(config)

timestamp = time.time()
success, image = capture.get_frame(config)
if not success:
Expand All @@ -29,4 +38,7 @@
print("Running at", frame_count, "fps")
frame_count = 0

objs = detector.run_inference(image)

image = draw_bbox(image, objs)
stream_server.set_frame(image)
9 changes: 9 additions & 0 deletions py/src/pipeline/Detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
import cv2 as cv


def draw_bbox(image: cv.Mat, objs: list[Object]) -> cv.Mat:
for obj in objs:
cv.rectangle(image,
(obj.bbox.xmin.item(), obj.bbox.ymin.item()),
(obj.bbox.xmax.item(), obj.bbox.ymax.item()),
(0, 255, 0))
return image


class Detector:
"""Runs a tflite model on the coral to detect objects"""
_labels: Dict[int, str]
Expand Down

0 comments on commit 5e09a31

Please sign in to comment.