You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
535 B
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

def analysis_yolov8(frame, model_coco, confidence):
# 第一步用COCO数据集推理
results_coco = model_coco(frame)
if not results_coco:
return []
boxes = results_coco[0].boxes
result_list = []
for box in boxes:
# 过滤置信度0.5以下目标
if float(box.conf) < confidence:
continue
labels_name = model_coco.names[int(box.cls)]
label_xyxy_dict = {labels_name: box.xyxy[0].tolist()}
result_list.append(label_xyxy_dict)
return result_list