Initial commit
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
|||||||
|
# Use PHP with Apache as the base image
|
||||||
|
FROM python:3.9-slim
|
||||||
|
|
||||||
|
#Copy Project
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
# Install any needed dependencies specified in requirements.txt
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Start Anonimization
|
||||||
|
CMD ["python", "app.py"]
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import cv2
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
img_path ="image.png"
|
||||||
|
treashold = float(5)
|
||||||
|
sever = os.environ['API_ROOT']
|
||||||
|
|
||||||
|
try:
|
||||||
|
r = requests.get('http://{}/local/detections/anonymize'.format(sever))
|
||||||
|
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
|
||||||
|
|
||||||
|
for detection in r.json():
|
||||||
|
img = cv2.imread(img_path)
|
||||||
|
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||||
|
faces, rejects, weights = face_cascade.detectMultiScale3(gray, 1.1, 4, outputRejectLevels = 1)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
for (x, y, w, h) in faces:
|
||||||
|
confidence = float(weights[i])
|
||||||
|
if (confidence > treashold):
|
||||||
|
face_roi = img[y:y+h, x:x+w]
|
||||||
|
blurred_face = cv2.GaussianBlur(face_roi, (99, 99), 20)
|
||||||
|
img[y:y+h, x:x+w] = blurred_face
|
||||||
|
|
||||||
|
print(weights[i])
|
||||||
|
text = "{}".format(weights[i])
|
||||||
|
cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)
|
||||||
|
cv2.putText(img, text, (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 255), 2)
|
||||||
|
|
||||||
|
i = i +1
|
||||||
|
|
||||||
|
cv2.imwrite(img_path, img)
|
||||||
|
|
||||||
|
except:
|
||||||
|
print("An exception occurred")
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
opencv-python
|
||||||
Reference in New Issue
Block a user