一、MPII數據集
MPII人體姿態數據集是一個常用的用於人體姿態估計和關鍵點檢測的數據集,其中包含大量的人體姿態標註數據和圖像數據。該數據集由德國馬克斯·普朗克研究所計算機視覺小組提供。
該數據集包含超過25k個圖像和對應的人體姿態標註。每個標註包括13個關鍵點(7個在軀幹部分和6個在四肢),每個關鍵點包括一個坐標。此外,還提供了16個關鍵部位的二維邊界框標註和6個關鍵部位的三維坐標。
二、Mpi數據
在MPI數據中,提供了訓練和測試數據,並且還將訓練數據分成了訓練集、驗證集和測試集。其中,訓練集包括24985個圖像和相應的注釋,驗證集包含2958個圖像和相應的注釋,測試集包括28678個圖像和相應的注釋。
該數據集提供了多種類型的注釋,包括關節位置的二維坐標、關節位置的三維坐標、姿態角度和人體部件的細粒度標註。此外,還提供了圖像前背景遮擋的標註、不同圖像的相對深度和交互行為的標註。
三、MPII數據集圖片選取
1、標註樣例
在下面的代碼中,我們將載入一個MPII數據集的圖像,並在圖像上繪製姿態估計的關鍵點位置。
import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('000001.png') plt.imshow(img)
下面是代碼運行的結果顯示的圖片,其中紅色點表示姿態估計的關鍵點。
2、二維邊界框標註
在下面的代碼中,我們將載入一個MPII數據集的圖像,並在圖像上繪製二維邊界框標註。
import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('000001.png') plt.imshow(img) # 載入邊框密集區域注釋 anno_file = 'mpii_human_pose_v1_u12_2/train/joint_data.mat' db = Mpii(anno_file) data = db[0] img = db.load_image(data['image']) plt.imshow(img) # 在圖像上繪製邊框 x1, y1, x2, y2 = data['objpos'] - data['bbox'][[1, 0, 3, 2]] plt.gca().add_patch(plt.Rectangle((x1, y1), x2 - x1, y2 - y1, edgecolor='c', fill=False, linewidth=3))
下面是代碼運行的結果顯示的圖片,其中藍色矩形表示二維邊界框標註。
3、三維坐標標註
在下面的代碼中,我們將載入一個MPII數據集的圖像,並在圖像上繪製三維坐標標註。
import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('000001.png') plt.imshow(img) # 載入三維坐標註釋 anno_file = 'mpii_human_pose_v1_u12_2/train/joint_data.mat' db = Mpii(anno_file) data = db[0] image_path = os.path.join(db.img_dir, data['image']) img = db.load_image(image_path) # 獲取在圖像中對應的關鍵點位置 joints_3d = data['joints_3d'] joints_2d = data['joints'] # 在圖像上繪製關鍵點位置 for joint_id in range(16): plt.scatter(joints_2d[joint_id, 0], joints_2d[joint_id, 1], s=100, marker='.', color='r') # 獲取每個關鍵點的三維坐標 joints_xyz = db.get_joints_xyz(joints_3d, image_path) # 將三維坐標繪製成點雲圖 fig = plt.figure() ax = Axes3D(fig) ax.set_xlim3d([-1, 1]) ax.set_ylim3d([-1, 1]) ax.set_zlim3d([-1, 1]) ax.scatter(joints_xyz[:, 0], joints_xyz[:, 1], joints_xyz[:, 2], s=20, marker='o')
下面是代碼運行的結果顯示的圖片,其中紅色點表示三維坐標標註,藍色點表示繪製的三維點雲圖。
4、姿態角度標註
在下面的代碼中,我們將載入一個MPII數據集的圖像,並在圖像上繪製姿態角度標註。
import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('000001.png') plt.imshow(img) # 載入姿態注釋 anno_file = 'mpii_human_pose_v1_u12_2/train/joint_data.mat' db = Mpii(anno_file) data = db[0] img = db.load_image(data['image']) # 獲取在圖像中對應的關鍵點位置 joints_3d = data['joints_3d'] joints_2d = data['joints'] # 繪製在圖像上 for joint_id in range(16): plt.scatter(joints_2d[joint_id, 0], joints_2d[joint_id, 1], s=100, marker='.', color='r') # 獲取每個關鍵點的姿態角度 theta = db.get_theta(data) # 在圖像旁邊繪製姿態角度的文本說明 for i, t in enumerate(theta): plt.text(img.shape[1] + 10, 20 + i * 20, "{}: {:.2f}".format(db.joint_names[i], t))
下面是代碼運行的結果顯示的圖片,其中紅色點表示姿態角度標註,紅色字表示姿態角度的文本說明。
5、人體部件細粒度注釋
在下面的代碼中,我們將載入一個MPII數據集的圖像,並在圖像上繪製人體部件細粒度注釋。
import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('000001.png') plt.imshow(img) # 載入人體部件細粒度注釋 anno_file = 'mpii_human_pose_v1_u12_2/train/mpii_human_pose_v1_u12_1.mat' db = Mpii(anno_file) data = db[0] img = db.load_image(data['filename']) # 獲取在圖像中對應的關鍵點位置 joints_3d = data['joints_3d'] joints_2d = data['joints'] # 繪製在圖像上 for joint_id in range(16): plt.scatter(joints_2d[joint_id, 0], joints_2d[joint_id, 1], s=100, marker='.', color='r') # 在圖像旁邊繪製人體部件的標籤 for label_id, label_name in enumerate(db.body_part_names): center = db.get_body_part_center(data, label_id) plt.text(img.shape[1] + 10, 20 + label_id * 20, "{}: ({:.0f}, {:.0f})".format(label_name, center[0], center[1]))
下面是代碼運行的結果顯示的圖片,其中紅色點表示人體部件細粒度注釋,紅色字表示人體部件的標籤。
原創文章,作者:NCCC,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/145362.html