Task #14812
Support #14808: création d'une vidéo au ralenti par opencv
capture des images a partir d'un video
Status: | New | Start date: | 11/22/2022 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | Awa Semou FAYE | % Done: | 0% | |
Category: | - | |||
Target version: | Polytech Projets GE - Troisième Itération 2022 | |||
Remaining (hours) |
Description
import cv2
import sched, time
s = sched.scheduler(time.time, time.sleep)
cam = cv2.VideoCapture(0)
cv2.namedWindow("test")
img_counter = 0
while True:
ret, frame = cam.read()
if not ret:
print("failed to grab frame")
break
cv2.imshow("test", frame)
k = cv2.waitKey(1)
if k%256 27:
# ESC pressed
print("Escape hit, closing...")
break
elif k%256 32:
# SPACE pressed
img_name = "opencv_frame_{}.png".format(img_counter)
cv2.imwrite(img_name, frame)
print("{} written!".format(img_name))
img_counter += 1
cam.release()
cv2.destroyAllWindows()
Related issues
History
#1 Updated by Sebastien LENGAGNE 2 months ago
- Copied from Task #14733: capture des images a partir d'un video added