人體關鍵點檢測對于描述人體姿态,預測人體行為至關重要。是以人體關鍵點檢測是諸多計算機視覺任務的基礎。其在動作分類,異常行為檢測,以及人機互動等領域有着很廣闊的應用前景,是計算機視覺領域中一個既具有研究價值、同時又極具挑戰性的熱門課題。圖展示了開源的人體關鍵點識别demo。
相關資料集
LSP(Leeds Sports Pose Dataset):單人人體關鍵點檢測資料集,關鍵點個數為14,樣本數2K,在目前的研究中基本上被棄用;
FLIC(Frames Labeled In Cinema):單人人體關鍵點檢測資料集,關鍵點個數為9,樣本數2W,在目前的研究中基本上被棄用;
MPII(MPII Human Pose Dataset):單人/多人人體關鍵點檢測資料集,關鍵點個數為16,樣本數25K;
MSCOCO:多人人體關鍵點檢測資料集,關鍵點個數為17,樣本數多于30W,目前的相關研究基本上還需要在該資料集上進行驗證;
AI Challenger:多人人體關鍵點檢測資料集,關鍵點個數為14,樣本數約38W,競賽資料集;
PoseTrack:最新的關于人體骨骼關鍵點的資料集,多人人體關鍵點跟蹤資料集,包含單幀關鍵點檢測、多幀關鍵點檢測、多人關鍵點跟蹤三個人物,多于500個視訊序列,幀數超過20K,關鍵點個數為15。
安裝與實踐
pytorch-openpose下載下傳pytorch版本的源碼之後,運作demo.py檔案
body_estimation = Body('model/body_pose_model.pth')
hand_estimation = Hand('model/hand_pose_model.pth')
test_image = 'images/demo.jpg'
oriImg = cv2.imread(test_image) # B,G,R order
candidate, subset = body_estimation(oriImg)
canvas = copy.deepcopy(oriImg)
canvas = util.draw_bodypose(canvas, candidate, subset)
# detect hand
hands_list = util.handDetect(candidate, subset, oriImg)
all_hand_peaks = []
for x, y, w, is_left in hands_list:
# cv2.rectangle(canvas, (x, y), (x+w, y+w), (0, 255, 0), 2, lineType=cv2.LINE_AA)
# cv2.putText(canvas, 'left' if is_left else 'right', (x, y), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
# if is_left:
# plt.imshow(oriImg[y:y+w, x:x+w, :][:, :, [2, 1, 0]])
# plt.show()
peaks = hand_estimation(oriImg[y:y+w, x:x+w, :])
peaks[:, 0] = np.where(peaks[:, 0]==0, peaks[:, 0], peaks[:, 0]+x)
peaks[:, 1] = np.where(peaks[:, 1]==0, peaks[:, 1], peaks[:, 1]+y)
# else:
# peaks = hand_estimation(cv2.flip(oriImg[y:y+w, x:x+w, :], 1))
# peaks[:, 0] = np.where(peaks[:, 0]==0, peaks[:, 0], w-peaks[:, 0]-1+x)
# peaks[:, 1] = np.where(peaks[:, 1]==0, peaks[:, 1], peaks[:, 1]+y)
# print(peaks)
all_hand_peaks.append(peaks)
canvas = util.draw_handpose(canvas, all_hand_peaks)
plt.imshow(canvas[:, :, [2, 1, 0]])
plt.axis('off')
plt.show()
pth檔案下載下傳位址 檢測效果
