Solution for Not drawing Keypoints OpenCV
is Given Below:
What I feel:
The draw_keypoints function isn’t called.
Please help me out I’m not able to figure what went wrong
I know that it will probably be an out-of-scope of function problem but still.
Code:
plt.imshow(frame)
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret,frame = cap.read()
#Reshape Image
img = frame.copy()
img = tf.image.resize_with_pad(np.expand_dims(img, axis=0), 256,256)
input_image= tf.cast(img, dtype=tf.float32)
#setup input and output
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
interpreter.set_tensor(input_details[0]['index'], np.array(input_image))
interpreter.invoke
keypoints_with_scores = interpreter.get_tensor(output_details[0]['index'])
draw_keypoints(frame, keypoints_with_scores, 0.4)
cv2.imshow('MoveNet Thunder', frame)
if cv2.waitKey(10) & 0xFF==ord('q'):
break
cap.release()
cv2.destroyAllWindows()
def draw_keypoints(frame, keypoints, confidence_threshold):
cv2.circle(frame, (200, 200), 7, (0,255,0), 3)
y, x, c = frame.shape
shaped = np.squeeze(np.multiply(keypoints,[y,x,1]))
for kp in shaped:
kx, ky, kc = kp
if kc > confidence_threshold:
cv2.circle(frame, (int(kx), int(ky)), 7, (0,255,0), 3)