diff --git a/apps/ai/main.py b/apps/ai/main.py index d01f5e34..2fd4abdd 100644 --- a/apps/ai/main.py +++ b/apps/ai/main.py @@ -38,11 +38,11 @@ def ai_analyse(codes: list, global_img: str, face_img: str = None): else: is_happend, res = f(ip=settings.AI_IP, pic_url=global_img) if i in ['fire1', 'jingjiedai', 'qiping']: # 如果是这3类算法就无需再识别,都在一个算法里处理了 + has_fire = False # 默认没有灭火器 + has_jingjiedai = False # 默认没有警戒带 + qiping_qd = False # 气瓶倾倒未发生 + rectangle_dict .update({'qiping': []}) # 气瓶倾倒的坐标字典 for x in res.FireinfoList: - has_fire = False # 默认没有灭火器 - has_jingjiedai = False # 默认没有警戒带 - qiping_qd = False # 气瓶倾倒未发生 - rectangle_dict .update({'qiping':[]}) # 气瓶倾倒的坐标字典 if x.fire == 3 and 'qiping' in codes: # 气瓶倾倒 qiping_qd = True rectangle_dict['qiping'].append([x.coord.x, x.coord.y]) # 加入矩形框 @@ -51,9 +51,9 @@ def ai_analyse(codes: list, global_img: str, face_img: str = None): if x.fire == 2: has_jingjiedai = True if (i == 'fire1' and not has_fire) or (i == 'jingjiedai' and not has_jingjiedai) or (i == 'qiping' and qiping_qd): - results.update({i: {'rectangles':rectangle_dict.get(i, [])}}) + results.update({i: {'rectangles': rectangle_dict.get(i, [])}}) if is_happend and (i not in results): - results.update({i: {'rectangles':rectangle_dict.get(i, [])}}) + results.update({i: {'rectangles': rectangle_dict.get(i, [])}}) except Exception: myLogger.error('算法处理错误', exc_info=True) return results