不绘制关键点 OpenCV

问题描述

我的感受:调用 draw_keypoints 函数。 请帮帮我我不知道出了什么问题 我知道这可能是功能范围外的问题,但仍然如此。

代码

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,1]))
    
    for kp in shaped:
        kx,ky,kc = kp
        if kc >  confidence_threshold:
            cv2.circle(frame,(int(kx),int(ky)),3)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)