|
@@ -125,15 +125,8 @@ class AiView(View):
|
|
|
file_post_three = request_dict.get('fileThree', None)
|
|
|
file_post_four = request_dict.get('fileFour', None)
|
|
|
|
|
|
- file_post_one = file_post_one.replace(' ', '+')
|
|
|
- file_post_two = file_post_two.replace(' ', '+')
|
|
|
- file_post_three = file_post_three.replace(' ', '+')
|
|
|
- file_post_four = file_post_four.replace(' ', '+')
|
|
|
-
|
|
|
- file_post_one = base64.b64decode(file_post_one)
|
|
|
- file_post_two = base64.b64decode(file_post_two)
|
|
|
- file_post_three = base64.b64decode(file_post_three)
|
|
|
- file_post_four = base64.b64decode(file_post_four)
|
|
|
+ if not all([file_post_one,file_post_two,file_post_three,file_post_four]):
|
|
|
+ return response.json(444)
|
|
|
|
|
|
file_list = [file_post_one, file_post_two, file_post_three, file_post_four]
|
|
|
del file_post_one, file_post_two, file_post_three, file_post_four
|
|
@@ -143,7 +136,8 @@ class AiView(View):
|
|
|
os.makedirs(dir_path)
|
|
|
file_path_list = []
|
|
|
for i, val in enumerate(file_list):
|
|
|
- # file_path = dir_path + '/' + str(i) + '.jpg'
|
|
|
+ val = val.replace(' ', '+')
|
|
|
+ val = base64.b64decode(val)
|
|
|
file_path = "{dir_path}/{n_time}_{i}.jpg".format(dir_path=dir_path, n_time=n_time, i=i)
|
|
|
file_path_list.append(file_path)
|
|
|
with open(file_path, 'wb') as f:
|
|
@@ -183,7 +177,7 @@ class AiView(View):
|
|
|
if len(labels['label_list']) == 0:
|
|
|
logger.info('没有识别到任何标签-----------------')
|
|
|
return response.json(10055)
|
|
|
- event_type_list = labels['label_type']
|
|
|
+ event_type_list = labels['user_detect_group']
|
|
|
label_list = ','.join(labels['label_list'])
|
|
|
logger.info(event_type_list)
|
|
|
logger.info(label_list)
|
|
@@ -259,7 +253,7 @@ class AiView(View):
|
|
|
kwargs = {
|
|
|
'uid': uid,
|
|
|
'channel': channel,
|
|
|
- 'event_type': labels['label_type'],
|
|
|
+ 'event_type': event_type_list,
|
|
|
'n_time': n_time,
|
|
|
'appBundleId': appBundleId,
|
|
|
'token_val': token_val,
|
|
@@ -316,7 +310,7 @@ class AiView(View):
|
|
|
label_name = []
|
|
|
logger.info('--------识别到的标签-------')
|
|
|
logger.info(labels)
|
|
|
- labels_type = {
|
|
|
+ all_labels_type = {
|
|
|
'1': ['Person', 'Human'], # 人
|
|
|
'2': ['Dog', 'Pet', 'Canine', 'Animal', 'Puppy'], # 动物
|
|
|
'3': ['Car', 'Vehicle', 'Transportation', 'Automobile'] # 车
|
|
@@ -326,29 +320,27 @@ class AiView(View):
|
|
|
label_name.append(label['Name'])
|
|
|
for Parents in label['Parents']:
|
|
|
label_name.append(Parents['Name'])
|
|
|
-
|
|
|
#删除用户没有选择的ai识别类型, 并且得出最终识别结果
|
|
|
user_detect_list = user_detect_group.split(',')
|
|
|
user_detect_list = [i.strip() for i in user_detect_list]
|
|
|
- label_result_list = []
|
|
|
- new_labels_type = labels_type
|
|
|
- for key, label_type in labels_type.items():
|
|
|
+ conform_label_list = []
|
|
|
+ conform_user_d_group = set()
|
|
|
+ for key, label_type_val in all_labels_type.items():
|
|
|
if key in user_detect_list:
|
|
|
- new_labels_type[key] = label_type
|
|
|
- for label in label_type:
|
|
|
+ for label in label_type_val:
|
|
|
if label in label_name:
|
|
|
- label_result_list.append(label)
|
|
|
-
|
|
|
+ conform_user_d_group.add(key)
|
|
|
+ conform_label_list.append(label)
|
|
|
#找出标签边框线位置信息
|
|
|
boundingBoxList = []
|
|
|
for label in labels:
|
|
|
- if label['Name'] in label_result_list:
|
|
|
+ if label['Name'] in conform_label_list:
|
|
|
for boundingBox in label['Instances']:
|
|
|
boundingBoxList.append(boundingBox['BoundingBox'])
|
|
|
|
|
|
#找出边框位置信息对应的单图位置并重新计算位置比
|
|
|
merge_image_height = image_size['height']
|
|
|
- merge_image_width = image_size['width']
|
|
|
+ # merge_image_width = image_size['width']
|
|
|
single_height = merge_image_height//image_size['num']
|
|
|
new_bounding_box_dict = {}
|
|
|
new_bounding_box_dict[n_time+'_0'] = []
|
|
@@ -368,14 +360,11 @@ class AiView(View):
|
|
|
boxDict['Height'] = merge_image_height*val['Height']/single_height
|
|
|
boxDict['Top'] = ((merge_image_height*val['Top'])-(i*single_height))/single_height #减去前i张图片的高度
|
|
|
boxDict['Left'] = val['Left']
|
|
|
- boxDict['picName'] = "{n_time}_{i}".format(n_time=n_time,i=i)
|
|
|
- # new_bounding_box_list.append(boxDict)
|
|
|
- # new_bounding_box_list.append(boxDict)
|
|
|
new_bounding_box_dict["{n_time}_{i}".format(n_time=n_time,i=i)].append(boxDict)
|
|
|
# exit(new_bounding_box_list)
|
|
|
- user_labels_list = list(new_labels_type.keys())
|
|
|
- user_labels_list.sort()
|
|
|
- return {'label_type': user_labels_list, 'label_list': label_result_list,
|
|
|
+ conform_user_d_group = list(conform_user_d_group)
|
|
|
+ conform_user_d_group.sort()
|
|
|
+ return {'user_detect_group': conform_user_d_group, 'label_list': conform_label_list,
|
|
|
'new_bounding_box_dict':new_bounding_box_dict}
|
|
|
|
|
|
|