逐行解释下列代码 def draw_game_rps(self, img, param):
img_height, img_width, _ = img.shape

# Init result of 2 hands to none
res = [None, None]

# Loop through different hands
for j, p in enumerate(param):
# Only allow maximum of two hands
if j>1:
break

if p[‘class’] is not None:
# Loop through keypoint for each hand
for i in range(21):
x = int(p[‘keypt’][i,0])
y = int(p[‘keypt’][i,1])
if x>0 and y>0 and x<img_width and y<img_height:
# Draw skeleton
start = p[‘keypt’][self.ktree[i],:]
x_ = int(start[0])
y_ = int(start[1])
if x_>0 and y_>0 and x_<img_width and y_<img_height:
cv2.line(img, (x_, y_), (x, y), self.color[i], 2)

# Draw keypoint
cv2.circle(img, (x, y), 5, self.color[i], -1)

# Label gesture
text = None
if p[‘gesture’]==‘fist’:
text = ‘rock’
elif p[‘gesture’]==‘five’:
text = ‘paper’
elif (p[‘gesture’]==‘three’) or (p[‘gesture’]==‘yeah’):
text = ‘scissor’
res[j] = text

# Label result
if text is not None:
x = int(p[‘keypt’][0,0]) - 30
y = int(p[‘keypt’][0,1]) + 40
cv2.putText(img, ‘%s’ % (text.upper()), (x, y),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), 2) # Red

# Determine winner
text = None
winner = None
if res[0]==‘rock’:
if res[1]==‘rock’ : text = ‘Tie’
elif res[1]==‘paper’ : text = ‘Paper wins’ ; winner = 1
elif res[1]==‘scissor’: text = ‘Rock wins’ ; winner = 0
elif res[0]==‘paper’:
if res[1]==‘rock’ : text = ‘Paper wins’ ; winner = 0
elif res[1]==‘paper’ : text = ‘Tie’
elif res[1]==‘scissor’: text = ‘Scissor wins’; winner = 1
elif res[0]==‘scissor’:
if res[1]==‘rock’ : text = ‘Rock wins’ ; winner = 1
elif res[1]==‘paper’ : text = ‘Scissor wins’; winner = 0
elif res[1]==‘scissor’: text = ‘Tie’

# Label gesture
if text is not None:
size = cv2.getTextSize(text.upper(),
# cv2.FONT_HERSHEY_SIMPLEX, 2, 2)[0]
cv2.FONT_HERSHEY_SIMPLEX, 1, 2)[0]
x = int((img_width-size[0]) / 2)
cv2.putText(img, text.upper(),
# (x, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0,0,255), 2)
(x, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), 2)

# Draw winner text
if winner is not None:
x = int(param[winner][‘keypt’][0,0]) - 30
y = int(param[winner][‘keypt’][0,1]) + 80
cv2.putText(img, ‘WINNER’, (x, y),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,255), 2) # Yellow

return img