in renderer/viewer2D.py [0:0]
def Vis_Skeleton_2D_H36m(pt2d, image = None, color=None):
pt2d = np.reshape(pt2d,[-1,2]) #Just in case. Make sure (32, 2)
#Draw via opencv
if not isinstance(image, np.ndarray):#not image: #If no image is given, generate Blank image
image = np.ones((1000,1000,3),np.uint8) *255
radius = 4
if(pt2d.shape[0]==16):
print("Vis_Skeleton_2D_H36m: {} joints".format(16))
#Without Nose
link2D = [ [0,1],[1,2],[2,3],#root(0), rHip(1), rKnee(2), rAnkle(3)
[0,4],[4,5],[5,6],#root(0, lHip(4), lKnee(5), lAnkle(6)
[0,7], [7,8], [8,9], #root(0, spineMid(7), neck(8), head(9)
[8,10], [10,11], [11,12], #Left Arms. neck(8). lshoulder(10), lElbow(11), lWrist (12)
[8,13], [13,14], [14,15] #Right Arm, neck(8), rshoulder(13), rElbow(14), rWrist (15)
]
bLeft = [ 0,0,0,
1, 1, 1,
1,1,1,
1,1,1,
0,0,0]
elif pt2d.shape[0]==17:
print("Vis_Skeleton_2D_H36m: {} joints".format(17))
#With Nose
link2D = [ [0,1],[1,2],[2,3],#root(0), rHip(1), rKnee(2), rAnkle(3)
[0,4],[4,5],[5,6],#root(0, lHip(4), lKnee(5), lAnkle(6)
[0,7], [7,8], [8,9], [9,10], #root(0, spineMid(7), neck(8), nose(9), head(9)
[8,11], [11,12], [12,13], #Left Arms. neck(8). lshoulder(11), lElbow(12), lWrist (13)
[8,14], [14,15], [15,16] #Right Arm, neck(8), rshoulder(14), rElbow(15), rWrist (16)
]
bLeft = [ 0,0,0,
1, 1, 1,
1,1,1, 1,
1,1,1,
0,0,0]
else:
print("Vis_Skeleton_2D_H36m: {} joints".format(32))
#Human 36m DB's mocap data. 32 joints
link2D = [ [0,1],[1,2],[2,3],[3,4],[4,5], #RightLeg: root(0), rHip(1), rKnee(2), rAnkle(3), rFootMid(4), rFootEnd(5)
[0,6],[6,7],[7,8],[8,9], [9,10], #LeftLeg: root, lHip(6), lKnee(7), lAnkle(8), lFootMid(9), lFootEnd(10)
[11,12], [12,13], [13,14], [14,15], #root2(11), spineMid(12), neck(13), nose(14), head(15) #0,11 are the same points?
[16,17], [17,18], [18,19], [20,21], [20,22], #Left Arms. neck(16==13), lshoulder(17), lElbow(18), lWrist (19=20), lThumb(21), lMiddleFinger(22)
[24,25], [25,26], [26,27], [27,29], [27,30] #Right Arm, neck(24==13), rshoulder(25), rElbow(26), rWrist (27=28), rThumb(29), rMiddleFinger(30)
]
bLeft = [0 ,0, 0, 0, 0,
1, 1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1, 1,
0, 0, 0, 0, 0] #To draw left as different color. Torso is treated as left
# for i in np.arange( len(link) ):
for k in np.arange( len(pt2d) ):
cv2.circle(image, (int(pt2d[k][0]), int(pt2d[k][1]) ), radius, (0,255,0),-1)
for k in np.arange( len(link2D) ):
parent = link2D[k][0]
child = link2D[k][1]
if color is not None:
c = color
else:
if bLeft[k]:
c = (0,0,255)#BGR, RED
else:
c = (0,0,0)
cv2.line(image, (int(pt2d[parent][0]), int(pt2d[parent][1])), (int(pt2d[child][0]), int(pt2d[child][1])), c, radius - 2)
return image