Little fix
This commit is contained in:
68
webcam.py
68
webcam.py
@@ -298,45 +298,45 @@ def make_prediction(keypoints):
|
||||
return c, score
|
||||
|
||||
# open webcam stream
|
||||
# cap = cv2.VideoCapture(0)
|
||||
cap = cv2.VideoCapture(0)
|
||||
|
||||
# while cap.isOpened():
|
||||
# # read frame
|
||||
# ret, frame = cap.read()
|
||||
# pose = extract_keypoints(frame)
|
||||
|
||||
# if pose is None:
|
||||
# cv2.imshow('MediaPipe Hands', frame)
|
||||
# continue
|
||||
|
||||
# buffer.append(pose)
|
||||
# if len(buffer) > 15:
|
||||
# buffer.pop(0)
|
||||
|
||||
# if len(buffer) == 15:
|
||||
# label, score = make_prediction(buffer)
|
||||
|
||||
# # draw label
|
||||
# cv2.putText(frame, label, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
|
||||
# cv2.putText(frame, str(score), (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
|
||||
|
||||
# # Show the frame
|
||||
# cv2.imshow('MediaPipe Hands', frame)
|
||||
|
||||
# # Wait for key press to exit
|
||||
# if cv2.waitKey(5) & 0xFF == 27:
|
||||
# break
|
||||
|
||||
# open video A.mp4
|
||||
cap = cv2.VideoCapture('E.mp4')
|
||||
while cap.isOpened():
|
||||
# read frame
|
||||
ret, frame = cap.read()
|
||||
if frame is None:
|
||||
break
|
||||
pose = extract_keypoints(frame)
|
||||
|
||||
if pose is None:
|
||||
cv2.imshow('MediaPipe Hands', frame)
|
||||
continue
|
||||
|
||||
buffer.append(pose)
|
||||
if len(buffer) > 15:
|
||||
buffer.pop(0)
|
||||
|
||||
if len(buffer) == 15:
|
||||
label, score = make_prediction(buffer)
|
||||
|
||||
# draw label
|
||||
cv2.putText(frame, label, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
|
||||
cv2.putText(frame, str(score), (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
|
||||
|
||||
# Show the frame
|
||||
cv2.imshow('MediaPipe Hands', frame)
|
||||
|
||||
# Wait for key press to exit
|
||||
if cv2.waitKey(5) & 0xFF == 27:
|
||||
break
|
||||
|
||||
# open video A.mp4
|
||||
# cap = cv2.VideoCapture('E.mp4')
|
||||
# while cap.isOpened():
|
||||
# # read frame
|
||||
# ret, frame = cap.read()
|
||||
# if frame is None:
|
||||
# break
|
||||
# pose = extract_keypoints(frame)
|
||||
|
||||
# buffer.append(pose)
|
||||
|
||||
label, score = make_prediction(buffer)
|
||||
print(label, score)
|
||||
# label, score = make_prediction(buffer)
|
||||
# print(label, score)
|
||||
Reference in New Issue
Block a user