Hi everyone,
I made a model in roboflow (Roboflow 3.0 model) to detect yellow goals, blue goals, and black walls, but when I tried to use the model with my phone the whole screen could detect the goals and walls. But when I put the model on my openMV N6 camera it only detected the goals and walls in a 400x400 square in the middle, I thought I fixed it by resizing the format in the pre-processing step to 640x480 and then making a new version of the model with the different format, but that didn’t do anything.
Here is my OpenMV code:
import csi
import time
import math
import ml
from ml.postprocessing.ultralytics import YoloV8
from machine import UART
import ustruct
# Initialize the sensor.
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
csi0.window((640, 480)) #((0, 170, 640, 200))
# Initialize bus, baudrate
uart = UART(3, 115200)
clock = time.clock()
# Load YOLO V8 model.
model = ml.Model("/rom/openmv_goal-and-wall-detection_v3.bin",
postprocess=YoloV8(threshold=0.4)
)
model.labels = ["Black wall", "blue-goal", "yellow-goal"]
# Colors
n = len(model.labels)
model_class_colors = [
(int(255 * i // n), int(255 * (n - i - 1) // n), 255)
for i in range(n)
]
while True:
clock.tick()
img = csi0.snapshot()
boxes = model.predict([img])
for i, class_detections in enumerate(boxes):
rects = [r for r, score in class_detections]
labels = [model.labels[i] for j in range(len(rects))]
colors = [model_class_colors[i] for j in range(len(rects))]
ml.utils.draw_predictions(img, rects, labels, colors, format=None)
for (x, y, w, h), score in class_detections:
center_x = math.floor(x + (w / 2))
center_y = math.floor(y + (h / 2))
rel_x = center_x - 320
rel_y = 240 - center_y
label = model.labels[i]
# Draw red line (this is your “tangent visualization”)
if label == "blue-goal" or label == "yellow-goal":
img.draw_line((320, 240, center_x, center_y), color=(255, 0, 0), thickness=2)
img.draw_circle((center_x, center_y, 5), color=(255, 255, 255))
Does anyone have an idea to make the camera detect goals and walls in the whole screen, instead of just the square in the middle?
Thank you very much!
