Browse Source

AI云上模型加入绘制边框参数

zhangdongming 2 năm trước cách đây
mục cha
commit
8e041533cd
1 tập tin đã thay đổi với 16 bổ sung2 xóa
  1. 16 2
      Controller/AiController.py

+ 16 - 2
Controller/AiController.py

@@ -112,7 +112,7 @@ class AiView(View):
             if event_type == 0:
                 CommonService.del_path(dir_path)
                 return response.json(0)
-            new_bounding_box_dict = ''
+            new_bounding_box_dict = ai_view.get_pic_coordinates(ai_results)
             # 上传缩略图到s3
             file_dict = {}
             for i, val in enumerate(file_path_list):
@@ -149,7 +149,7 @@ class AiView(View):
                         receive_time=receive_time,
                         add_time=now_time,
                         storage_location=2,
-                        border_coords=json.dumps(new_bounding_box_dict)
+                        border_coords=new_bounding_box_dict
                     ))
                     user_id_list.append(user_id)
 
@@ -263,6 +263,20 @@ class AiView(View):
         else:
             return 0
 
+    @classmethod
+    def get_pic_coordinates(cls, results):
+        """
+        获取识别图片坐标
+        """
+        try:
+            ai_dict = {}
+            for i in range(3):
+                ai_dict['file_' + str(i)] = results['pic_' + str(i)]
+            return json.dumps(ai_dict)
+        except Exception as e:
+            LOGGING.info('AI推理结果解析异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
+            return ''
+
     @staticmethod
     def get_tag_message(lang, event_type):
         event_type = str(event_type)