【发布时间】:2021-10-19 20:56:22
【问题描述】:
我试图只显示地标和 2d 插图,而不显示它们背后的视频源,但无济于事。这似乎我应该有一个非常简单的答案,但我迷路了。有人知道如何去做吗?
#dependencies
import cv2
import mediapipe as mp
import numpy as np
mp_drawing = mp.solutions.drawing_utils
mp_holistic = mp.solutions.holistic
cap = cv2.VideoCapture(0)
#mediapipe instance
with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
while cap.isOpened():
ret, frame = cap.read()
frame.flags.writeable = False
#make detection
results = holistic.process(frame)
#render detections
mp_drawing.draw_landmarks(frame, results.face_landmarks, mp_holistic.FACE_CONNECTIONS,
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1),
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1)
)
mp_drawing.draw_landmarks(frame, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS,
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1),
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1)
)
mp_drawing.draw_landmarks(frame, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS,
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1),
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1)
)
mp_drawing.draw_landmarks(frame, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS,
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1),
mp_drawing.DrawingSpec(color=(256, 256, 256), thickness=1, circle_radius=1)
)
cv2.imshow('frame', frame)
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
【问题讨论】:
-
嗨@aidan.goetzinger :) 欢迎来到stackoverflow。我认为您应该删除 cv2.imshow('frame', frame) 行
-
或者你可以制作一个空图像,绘制地标并显示它而不是框架:)
标签: python opencv artificial-intelligence mediapipe