i want the frame evey second from the stream of my webcam?
I am doing a project in python and i want the every second frame from the steam of my webcam.
I am doing a project in python and i want the every second frame from the steam of my webcam.
I am using OpenCV 4.0.1. For 640x480 set to VedeoCapture to 1. Set to zero will be 320x480. I am using raspberry pi 3B/+, Linus.
import cv2
cap = cv2.VideoCapture(1)
count = 0
while cap.isOpened():
ret, frame = cap.read()
if ret:
cv2.imwrite('frame{:d}.jpg'.format(count), frame)
count += 30 # i.e. at 30 fps, this advances one second
cap.set(1, count)
else:
cap.release()
break
Or
import numpy as np
import cv2
import time
cap = cv2.VideoCapture(1)
while True:
start_time = time.time()
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
time.sleep(1.0 - time.time() + start)
cap.release()
cv2.destroyAllWindows()
Asked: 2019-01-31 06:32:36 -0600
Seen: 3,089 times
Last updated: Jan 31 '19
Area of a single pixel object in OpenCV
OpenCV DescriptorMatcher matches
Conversion between IplImage and MxArray
Computer Vision - Craps Coach Project from a Newbie
how to understand which functions available in python bindings?
How to set resolution of video capture in python with Logitech c910 & c920
Problems installing opencv on mac with python