0

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
  • 1
    Your code does not seem to have any part that would make it a web application. – Klaus D. Apr 07 '22 at 04:14
  • i can run the file from flask and It is running fine, but i want it to run automatically when i click a button on HTML page. is that possible ? – Rakshit Shah Apr 07 '22 at 04:16
  • I would take a look at this first: https://stackoverflow.com/questions/40844903/how-to-run-python-script-in-html – Peter Missick Apr 21 '22 at 03:25
  • Does this answer your question? [How can I run a Python script in HTML?](https://stackoverflow.com/questions/40844903/how-can-i-run-a-python-script-in-html) – Peter Missick Jul 21 '22 at 04:35

0 Answers0