Skip to content

Instantly share code, notes, and snippets.

# Written by Luis Mesas
import threading
import time
import cv2
# Define video capture class
class VideoCaptureAsync:
def __init__(self, src=0, width=640, height=480, driver=None):
self.src = src
if driver is None:
# Import the recording process
from camera_record import record_video
# set recording duration
record_time = 20
# To run this as part of a bigger program, use mutltiprocessing to create a seperate process
# for video recording using the following lines.
from multiprocessing import Process
# The line above can go to the top of your file and the following lines should be placed
# where ever you need to record a video
# Create the process thread object
import cv2
# Import the video capturing function
from video_capture import VideoCaptureAsync
import time
#Specify width and height of video to be recorded
vid_w = 1280
vid_h = 720
#Intiate Video Capture object
capture = VideoCaptureAsync(src=0, width=vid_w, height=vid_h)