From 2e20427a1e082096f2a927f3a7808bcca32c3219 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sat, 23 Sep 2023 02:45:14 +0700 Subject: [PATCH] Create face_analyzer.py --- access_control_python/face_analyzer.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 access_control_python/face_analyzer.py diff --git a/access_control_python/face_analyzer.py b/access_control_python/face_analyzer.py new file mode 100644 index 0000000..053d9cb --- /dev/null +++ b/access_control_python/face_analyzer.py @@ -0,0 +1,23 @@ +import numpy as np +import cv2 +import base64 +import requests +import json +cam = cv2.VideoCapture(0) + +while True: + ret, img = cam.read() + ret, jpg_buffer = cv2.imencode('.jpg',img) + b64_img = base64.b64encode(jpg_buffer) + data = {"image":b64_img.decode("utf-8")} + res = requests.post("https://racist.siwatsystem.com/process_image",json=data) + res = res.content.decode("utf-8") + res = json.loads(res) + #print(req) + if len(res) >0: + if (res[0]['dominant_race']=="asian"): + print("Ching Chong") + elif(res[0]['dominant_race']=="black"): + print("CRIMINAL!!") + elif (res[0]['dominant_race']=="white"): + print("Ding Dong") \ No newline at end of file