diff --git a/apps/ai/client.py b/apps/ai/client.py index c30c70a4..c96b530a 100644 --- a/apps/ai/client.py +++ b/apps/ai/client.py @@ -46,14 +46,14 @@ def fire1(ip: str, pic_url: str): # 未配置灭火器事件 channel = grpc.insecure_channel(ip+':2001') stub = BeiHangGrpc_pb2_grpc.Fire_RegStub(channel) - image_id = 3 + image_id = 3 img_name = '{}.png'.format(uuid.uuid4()) img_path = settings.BASE_DIR + '/temp/' + img_name with open(img_path, "wb") as f: - f.write(requests.get(url=pic_url, verify=False).content).read()) + f.write(requests.get(url=pic_url, verify=False).content) img = cv2.imread(img_path) - resized_img = cv2.resize(img, None, fx=0.25,fy=0.25) - resized_img = cv2.imencode('.png',resized_img)[1] + resized_img = cv2.resize(img, None, fx=0.25, fy=0.25) + resized_img = cv2.imencode('.png', resized_img)[1] image_base64 = str(base64.b64encode(resized_img))[2:-1] request = BeiHangGrpc_pb2.JinYu_Request(zzid=image_id, imgsbase64=image_base64) @@ -65,10 +65,6 @@ def fire1(ip: str, pic_url: str): return True, response - - - - if __name__ == "__main__": path = 'http://10.99.5.24/evo-apigw/evo-oss/6ad010cf-ce45-11ec-9715-e4246c7d1635/20220826/1/dsf_3de82501-2521-11ed-884a-e4246c7d1635_7236037_7245601.jpg?token=399773e6-71f7-4202-b234-ff5aa8d2492c' base64img = str(base64.b64encode(BytesIO(requests.get(url=path, verify=False).content).read()), 'utf-8') @@ -77,4 +73,4 @@ if __name__ == "__main__": is_happend, res = analyse( ip='122.224.229.24:2000', pic_url='http://10.99.5.24/evo-apigw/evo-oss/6ad010cf-ce45-11ec-9715-e4246c7d1635/20220826/1/dsf_3de82501-2521-11ed-884a-e4246c7d1635_7236037_7245601.jpg?token=399773e6-71f7-4202-b234-ff5aa8d2492c') - print(is_happend, res.helmetinfoList[0].head_helmet) \ No newline at end of file + print(is_happend, res.helmetinfoList[0].head_helmet)