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.
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
person_result_list = [ ]
head_result_list = [ ]
phone_result_list = [ ]
for box in boxes :
labels_name = model_coco . names [ int ( box . cls ) ]
if labels_name == ' person ' :
if float ( box . conf ) > = confidence [ ' person ' ] :
label_xyxy_dict = { labels_name : box . xyxy [ 0 ] . tolist ( ) }
person_result_list . append ( label_xyxy_dict )
elif labels_name == ' head ' :
if float ( box . conf ) > = confidence [ ' head ' ] :
label_xyxy_dict = { labels_name : box . xyxy [ 0 ] . tolist ( ) }
head_result_list . append ( label_xyxy_dict )
else :
if float ( box . conf ) > = confidence [ ' phone ' ] :
label_xyxy_dict = { labels_name : box . xyxy [ 0 ] . tolist ( ) }
phone_result_list . append ( label_xyxy_dict )
return person_result_list , head_result_list , phone_result_list