Spaces:
Sleeping
Sleeping
Update Face_Censoring.py
Browse files- Face_Censoring.py +7 -1
Face_Censoring.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import cv2
|
| 2 |
import streamlit as st
|
|
|
|
| 3 |
|
| 4 |
def censor_face(filePath):
|
| 5 |
|
|
@@ -10,12 +11,17 @@ def censor_face(filePath):
|
|
| 10 |
|
| 11 |
height = frame.shape[0]
|
| 12 |
width = frame.shape[1]
|
|
|
|
|
|
|
| 13 |
|
| 14 |
face_cascade=cv2.CascadeClassifier('XML\faces.xml')
|
|
|
|
|
|
|
|
|
|
| 15 |
output=cv2.VideoWriter(output_file, cv2.VideoWriter_fourcc(*'mp4v'), 30, (width, height))
|
| 16 |
|
| 17 |
while success:
|
| 18 |
-
faces =
|
| 19 |
for (x,y, w, h) in faces: #multiple faces in a video
|
| 20 |
frame[y:y+h, x:x+w] = cv2.blur(frame[y:y+h, x:x+w], (150, 150))
|
| 21 |
output.write(frame)
|
|
|
|
| 1 |
import cv2
|
| 2 |
import streamlit as st
|
| 3 |
+
import tempfile
|
| 4 |
|
| 5 |
def censor_face(filePath):
|
| 6 |
|
|
|
|
| 11 |
|
| 12 |
height = frame.shape[0]
|
| 13 |
width = frame.shape[1]
|
| 14 |
+
|
| 15 |
+
print(height, width)
|
| 16 |
|
| 17 |
face_cascade=cv2.CascadeClassifier('XML\faces.xml')
|
| 18 |
+
tfile2 = tempfile.NamedTemporaryFile(delete=False)
|
| 19 |
+
tfile2.write(face_cascade.read())
|
| 20 |
+
|
| 21 |
output=cv2.VideoWriter(output_file, cv2.VideoWriter_fourcc(*'mp4v'), 30, (width, height))
|
| 22 |
|
| 23 |
while success:
|
| 24 |
+
faces = tfile2.detectMultiScale(frame, 1.1, 4)
|
| 25 |
for (x,y, w, h) in faces: #multiple faces in a video
|
| 26 |
frame[y:y+h, x:x+w] = cv2.blur(frame[y:y+h, x:x+w], (150, 150))
|
| 27 |
output.write(frame)
|