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