import numpy as np import cv2 import base64 import requests import json #api_server = "http://localhost:5000" api_server = "http://192.168.0.239" #api_server = "https://racist.siwatsystem.com" def analyze_face(img): endpoint = api_server +"/process_image" ret, jpg_buffer = cv2.imencode('.jpg',img) b64_img = base64.b64encode(jpg_buffer) data = {"image":b64_img.decode("utf-8")} req = requests.post(endpoint,json=data) res = res.content.decode("utf-8") try: res = json.loads(res) except: pass return res def identify_face(img, target_condidence: float): endpoint = api_server +"/identify_face" ret, jpg_buffer = cv2.imencode('.jpg',img) b64_img = base64.b64encode(jpg_buffer) data = {"image":b64_img.decode("utf-8"),"target_confidence": target_condidence} req = requests.post(endpoint,json=data) res = req.content.decode("utf-8") print(res) try: res = json.loads(res) except: pass return res