I have this while loop that takes a video and does the detection and clasification of some objects. I use yolov8 as a detector and efficientnetB3 as classifier. It works well but it does the detection and classification tasks in every moment. Now I want to change it in order to execute these tasks only when an object is stopped on the ground. How can I resolve it? I cannot use the yolo tracker, can I use someother tracker or can I somehow work on centroids without any tracker??
`while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
results = detector(frame)
detections = results[0].boxes
for box in detections:
x1, y1, x2, y2 = box.xyxy[0].tolist()
roi = frame[int(y1):int(y2), int(x1):int(x2)]
roi = Image.fromarray(roi)
image = transform(roi)
image = torch.unsqueeze(image, 0)
image = image.to(DEVICE)
with torch.no_grad():
outputs = model(image)
pred_idx = torch.argmax(outputs, dim=1).item()
pred_class_name = class_names[pred_idx]
prob = torch.softmax(outputs, dim=1)[0, pred_idx].item() * 100
prob_str = f'{prob:.2f}%'
if prob < 0.60:
pred_class_name = 'other'
label = f'Class: {pred_class_name}, conf: {prob_str}'
cv2.rectangle(frame, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2)
cv2.putText(frame, label, (int(x1), int(y1) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
out.write(frame)`
I cannot use the yolo tracker, can I use someother tracker or can I somehow work on centroids without any tracker??