def plotJoints(self, ax, joint, color='nice', jcolor=None, annoscale=1):
"""
Plot connected joints
:param ax: axis to plot on
:param joint: joints to connect
:param color: line color
"""
if joint.shape[0] >= numpy.max(self.jointConnections):
for i in range(len(self.jointConnections)):
if isinstance(ax, numpy.ndarray):
if color == 'nice':
lc = tuple((self.jointConnectionColors[i]*255.).astype(int))
elif color == 'gray':
lc = tuple((rgb_to_gray(self.jointConnectionColors[i])*255.).astype(int))
else:
lc = color
cv2.line(ax, (int(numpy.rint(joint[self.jointConnections[i][0], 0])),
int(numpy.rint(joint[self.jointConnections[i][0], 1]))),
(int(numpy.rint(joint[self.jointConnections[i][1], 0])),
int(numpy.rint(joint[self.jointConnections[i][1], 1]))),
lc, thickness=3*annoscale, lineType=cv2.CV_AA)
else:
if color == 'nice':
lc = self.jointConnectionColors[i]
elif color == 'gray':
lc = rgb_to_gray(self.jointConnectionColors[i])
else:
lc = color
ax.plot(numpy.hstack((joint[self.jointConnections[i][0], 0], joint[self.jointConnections[i][1], 0])),
numpy.hstack((joint[self.jointConnections[i][0], 1], joint[self.jointConnections[i][1], 1])),
c=lc, linewidth=3.0*annoscale)
for i in range(joint.shape[0]):
if isinstance(ax, numpy.ndarray):
if jcolor == 'nice':
jc = tuple((self.jointColors[i]*255.).astype(int))
elif jcolor == 'gray':
jc = tuple((rgb_to_gray(self.jointColors[i])*255.).astype(int))
else:
jc = jcolor
cv2.circle(ax, (int(numpy.rint(joint[i, 0])), int(numpy.rint(joint[i, 1]))), 6*annoscale,
jc, thickness=-1, lineType=cv2.CV_AA)
else:
if jcolor == 'nice':
jc = self.jointColors[i]
elif jcolor == 'gray':
jc = rgb_to_gray(self.jointColors[i])
else:
jc = jcolor
ax.scatter(joint[i, 0], joint[i, 1], marker='o', s=100,
c=jc)
评论列表
文章目录