Skip to content

Commit

Permalink
added 2025_feb_15 test script
Browse files Browse the repository at this point in the history
  • Loading branch information
UA-24 X500 Pi committed Feb 15, 2025
1 parent d20e2af commit d140355
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dep/labeller
Submodule labeller updated 1 files
+75 −0 benchmarks/yolov10.py
Binary file modified src/flight_tests/.ft_camera_log.py.swp
Binary file not shown.
32 changes: 23 additions & 9 deletions src/flight_tests/ft_2025_02_08.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import time
import os
from PIL import Image

from PIL import Image, ImageDraw
import numpy as np
from src.modules.imaging.camera import RPiCamera
from dep.labeller.benchmarks.yolov10 import YoloDetector
#from src.modules.imaging.mavlink import MAVLinkDelegate
Expand All @@ -28,28 +28,42 @@ def take_picture(_):
global last_picture

now = time.time()
if now - last_picture < 5:
return
#if now - last_picture < 5:
# return
last_picture = now

cam.caputure_to(f"tmp/log/{ft_num}/{i}.png")
path = f"tmp/log/{ft_num}/{i}.png"
cam.caputure_to(path)
#location.dump_to(f"tmp/log/{ft_num}/{i}.json")
print(i)
i += 1
return (f"tmp/log/{ft_num}/{i}.png")
return path


def predict(pathToImage: str):
image = Image.open(pathToImage)
results = model.predict(image)
draw_bbox(image, results)
with open('tmp/2025_02_08.log', 'w') as file:
file.write(results)
file.write(str(results))
print(results)

def draw_bbox(image: Image.Image, results: dict):

draw = ImageDraw.Draw(image)

for result in results:
x1 = result['x'] - result['w'] // 2
y1 = result['y'] - result['h'] // 2
x2 = result['x'] + result['w'] // 2
y2 = result['y'] + result['h'] // 2

draw.rectangle([x1, y1, x2, y2], outline='red', width=3)

image.show()

while True:
predict(take_picture(None))
time.sleep(5)
time.sleep(1)

#mavlink.subscribe(take_picture)
#mavlink.run()
Expand Down
4 changes: 2 additions & 2 deletions src/modules/imaging/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def __init__(self):
self.size = (1920, 1080)
self.configure_camera()
self.camera.start()
print(self.camera.capture_metadata()['ScalarCrop'])
print(self.camera.camera_controls['ScalarCrop'])
print(self.camera.capture_metadata()['ScalerCrop'])
print(self.camera.camera_controls['ScalerCrop'])

def configure_camera(self):
# Configuring camera properties
Expand Down
2 changes: 1 addition & 1 deletion third_party/yolov5
Submodule yolov5 updated 138 files

0 comments on commit d140355

Please sign in to comment.