I draw human body coordinate points on a black window, but the coordinate points will remain even if there is no human body in that place.How to make these points disappear normally.This is code.
import cv2
import numpy as np
import mediapipe as mp
# Create a VideoCapture object and read from input file
# If the input is the camera, pass 0 instead of the video file name
cap = cv2.VideoCapture('show.mp4')
height,width=480,852
blank_image = np.zeros((height,width,3), np.uint8)
mp_drawing = mp.solutions.drawing_utils
mp_pose = mp.solutions.pose
with mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5) as pose:
while (cap.isOpened()):
ret, frame = cap.read()
if ret :
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image.flags.writeable = False
results=pose.process(image)
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
mp_drawing.draw_landmarks(blank_image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,
mp_drawing.DrawingSpec(color=(245, 117, 66), thickness=2, circle_radius=2),
mp_drawing.DrawingSpec(color=(245, 66, 230), thickness=2, circle_radius=2)
)
cv2.imshow("",image)
cv2.imshow(" ",blank_image)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
# Break the loop
else:
break
# When everything done, release the video capture object
cap.release()
# Closes all the frames
cv2.destroyAllWindows()
this is the image
When I draw points on the body, points disappeared, but not on a black image.