Fixes
This commit is contained in:
@@ -2,18 +2,25 @@ import cv2
|
||||
import time
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
|
||||
treashold = float(os.getenv('FACE_TRASHOLD', '0,5'))
|
||||
sever = os.getenv('API_ROOT', 'localhost')
|
||||
treashold = float(os.getenv('FACE_TRASHOLD', '0.5'))
|
||||
sever = os.getenv('API_ROOT', 'localhost:8000')
|
||||
root_api_url = 'http://{}/local'.format(sever)
|
||||
|
||||
try:
|
||||
while True:
|
||||
r = requests.get('{}/anonymize'.format(root_api_url))
|
||||
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
|
||||
response = r.json()
|
||||
|
||||
for detection in response:
|
||||
img_path = "/data/{}".format(detection['source_image_path'])
|
||||
|
||||
#Skip Non existing files
|
||||
if (not os.path.exists(img_path)):
|
||||
continue
|
||||
|
||||
for detection in r.json():
|
||||
img_path = "/data/{}".format(detection.source_image_path)
|
||||
img = cv2.imread(img_path)
|
||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
faces, rejects, weights = face_cascade.detectMultiScale3(gray, 1.1, 4, outputRejectLevels = 1)
|
||||
@@ -38,14 +45,14 @@ try:
|
||||
cv2.imwrite(new_img_path, img)
|
||||
|
||||
data = {
|
||||
"id": detection.id,
|
||||
"id": detection['id'],
|
||||
"source_image_path": new_img_path
|
||||
}
|
||||
response = requests.post('{}/anonymize'.format(root_api_url), json=data)
|
||||
|
||||
time.sleep(3)
|
||||
time.sleep(900)
|
||||
|
||||
except Exception as e:
|
||||
print("An exception occurred")
|
||||
data = {"trace": e.__traceback__,}
|
||||
data = {"trace": str(e)}
|
||||
response = requests.post('{}/log'.format(root_api_url), json=data)
|
||||
Reference in New Issue
Block a user