Below is a Python script intended to record video. I would like to have the code below run when I click a button on an HTML page. What code/methods could I use to make this possible?
import cv2
import numpy as np
from cv2 import VideoWriter
from cv2 import VideoWriter_fourcc
# open the webcam video stream
webcam = cv2.VideoCapture(0)
fourcc=cv2.VideoWriter_fourcc(*'mpv4')
out= cv2.VideoWriter('VideoRecord.mp4',fourcc,20.0,(640,480))
while (webcam.isOpened()):
ret, frame=webcam.read()
if(ret==True):
out.write(frame)
cv2.imshow('output',frame)
if(cv2.waitKey(1)==ord('q')):
break
else:
break
webcam.release()
cv2.destroyAllWindows