Create face_analyzer.py

This commit is contained in:
Siwat Sirichai 2023-09-23 02:45:14 +07:00
parent 1b33ce0832
commit 2e20427a1e
1 changed files with 23 additions and 0 deletions

View File

@ -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")