import cv2 import streamlit as st import tempfile try: face_cascade = cv2.CascadeClassifier('XML/faces.xml') except Exception: st.write("Error loading cascade classifiers") def censor_face(filePath): output_file = 'Output/censored_' + str(filePath.name) + '.mp4' video=cv2.VideoCapture(filePath.name) success, frame = video.read() height = frame.shape[0] width = frame.shape[1] #st.write(height, width) #gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) #st.write("Frame: " + str(frame)) output=cv2.VideoWriter(output_file, cv2.VideoWriter_fourcc(*'mp4v'), 30, (width, height)) while success: faces = face_cascade.detectMultiScale(frame, 1.1, 4) for (x,y, w, h) in faces: #multiple faces in a video frame[y:y+h, x:x+w] = cv2.blur(frame[y:y+h, x:x+w], (150, 150)) output.write(frame) success, frame = video.read() output.release() st.write(type(output)) st.write(type(frame)) return output