yolov8进行关键点检测的代码如下:
from ultralytics import YOLO# Load a model
model = YOLO('yolov8n.pt') # pretrained YOLOv8n model# Run batched inference on a list of images
results = model(['im1.jpg', 'im2.jpg']) # return a list of Results objects# Process results list
for result in results:boxes = result.boxes # Boxes object for bounding box outputsmasks = result.masks # Masks object for segmentation masks outputskeypoints = result.keypoints # Keypoints object for pose outputsprobs = result.probs # Probs object for classification outputsresult.show() # display to screenresult.save(filename='result.jpg') # save to disk
输出的keypoint顺序如下:
“keypoints”: [“nose”,“left_eye”,“right_eye”,“left_ear”,“right_ear”,“left_shoulder”,“right_shoulder”,“left_elbow”,“right_elbow”,“left_wrist”,“right_wrist”,“left_hip”,“right_hip”,“left_knee”,“right_knee”,“left_ankle”,“right_ankle”],
对两张图进行测试:
:
对应的输出格式如下,没有检测到的为(0,0):
第二张图片