一、MPII數(shù)據(jù)集
MPII人體姿態(tài)數(shù)據(jù)集是一個(gè)常用的用于人體姿態(tài)估計(jì)和關(guān)鍵點(diǎn)檢測(cè)的數(shù)據(jù)集,其中包含大量的人體姿態(tài)標(biāo)注數(shù)據(jù)和圖像數(shù)據(jù)。該數(shù)據(jù)集由德國(guó)馬克斯·普朗克研究所計(jì)算機(jī)視覺(jué)小組提供。
該數(shù)據(jù)集包含超過(guò)25k個(gè)圖像和對(duì)應(yīng)的人體姿態(tài)標(biāo)注。每個(gè)標(biāo)注包括13個(gè)關(guān)鍵點(diǎn)(7個(gè)在軀干部分和6個(gè)在四肢),每個(gè)關(guān)鍵點(diǎn)包括一個(gè)坐標(biāo)。此外,還提供了16個(gè)關(guān)鍵部位的二維邊界框標(biāo)注和6個(gè)關(guān)鍵部位的三維坐標(biāo)。
二、Mpi數(shù)據(jù)
在MPI數(shù)據(jù)中,提供了訓(xùn)練和測(cè)試數(shù)據(jù),并且還將訓(xùn)練數(shù)據(jù)分成了訓(xùn)練集、驗(yàn)證集和測(cè)試集。其中,訓(xùn)練集包括24985個(gè)圖像和相應(yīng)的注釋,驗(yàn)證集包含2958個(gè)圖像和相應(yīng)的注釋,測(cè)試集包括28678個(gè)圖像和相應(yīng)的注釋。
該數(shù)據(jù)集提供了多種類型的注釋,包括關(guān)節(jié)位置的二維坐標(biāo)、關(guān)節(jié)位置的三維坐標(biāo)、姿態(tài)角度和人體部件的細(xì)粒度標(biāo)注。此外,還提供了圖像前背景遮擋的標(biāo)注、不同圖像的相對(duì)深度和交互行為的標(biāo)注。
三、MPII數(shù)據(jù)集圖片選取
1、標(biāo)注樣例
在下面的代碼中,我們將加載一個(gè)MPII數(shù)據(jù)集的圖像,并在圖像上繪制姿態(tài)估計(jì)的關(guān)鍵點(diǎn)位置。
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('000001.png')
plt.imshow(img)
下面是代碼運(yùn)行的結(jié)果顯示的圖片,其中紅色點(diǎn)表示姿態(tài)估計(jì)的關(guān)鍵點(diǎn)。
2、二維邊界框標(biāo)注
在下面的代碼中,我們將加載一個(gè)MPII數(shù)據(jù)集的圖像,并在圖像上繪制二維邊界框標(biāo)注。
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('000001.png')
plt.imshow(img)
# 加載邊框密集區(qū)域注釋
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))
下面是代碼運(yùn)行的結(jié)果顯示的圖片,其中藍(lán)色矩形表示二維邊界框標(biāo)注。
3、三維坐標(biāo)標(biāo)注
在下面的代碼中,我們將加載一個(gè)MPII數(shù)據(jù)集的圖像,并在圖像上繪制三維坐標(biāo)標(biāo)注。
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('000001.png')
plt.imshow(img)
# 加載三維坐標(biāo)注釋
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)
# 獲取在圖像中對(duì)應(yīng)的關(guān)鍵點(diǎn)位置
joints_3d = data['joints_3d']
joints_2d = data['joints']
# 在圖像上繪制關(guān)鍵點(diǎn)位置
for joint_id in range(16):
plt.scatter(joints_2d[joint_id, 0], joints_2d[joint_id, 1], s=100, marker='.', color='r')
# 獲取每個(gè)關(guān)鍵點(diǎn)的三維坐標(biāo)
joints_xyz = db.get_joints_xyz(joints_3d, image_path)
# 將三維坐標(biāo)繪制成點(diǎn)云圖
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')
下面是代碼運(yùn)行的結(jié)果顯示的圖片,其中紅色點(diǎn)表示三維坐標(biāo)標(biāo)注,藍(lán)色點(diǎn)表示繪制的三維點(diǎn)云圖。
4、姿態(tài)角度標(biāo)注
在下面的代碼中,我們將加載一個(gè)MPII數(shù)據(jù)集的圖像,并在圖像上繪制姿態(tài)角度標(biāo)注。
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('000001.png')
plt.imshow(img)
# 加載姿態(tài)注釋
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'])
# 獲取在圖像中對(duì)應(yīng)的關(guān)鍵點(diǎn)位置
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')
# 獲取每個(gè)關(guān)鍵點(diǎn)的姿態(tài)角度
theta = db.get_theta(data)
# 在圖像旁邊繪制姿態(tài)角度的文本說(shuō)明
for i, t in enumerate(theta):
plt.text(img.shape[1] + 10, 20 + i * 20, "{}: {:.2f}".format(db.joint_names[i], t))
下面是代碼運(yùn)行的結(jié)果顯示的圖片,其中紅色點(diǎn)表示姿態(tài)角度標(biāo)注,紅色字表示姿態(tài)角度的文本說(shuō)明。
5、人體部件細(xì)粒度注釋
在下面的代碼中,我們將加載一個(gè)MPII數(shù)據(jù)集的圖像,并在圖像上繪制人體部件細(xì)粒度注釋。
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('000001.png')
plt.imshow(img)
# 加載人體部件細(xì)粒度注釋
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'])
# 獲取在圖像中對(duì)應(yīng)的關(guān)鍵點(diǎn)位置
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')
# 在圖像旁邊繪制人體部件的標(biāo)簽
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]))
下面是代碼運(yùn)行的結(jié)果顯示的圖片,其中紅色點(diǎn)表示人體部件細(xì)粒度注釋,紅色字表示人體部件的標(biāo)簽。