1)新增M027:建筑物下行人检测及计数 2)密集人群计数模型及自研车牌模型优化 3)分类模型支持pt模型加载(巴中水利)
This commit is contained in:
parent
98480b45d6
commit
b75a74d52c
|
|
@ -27,7 +27,6 @@ class FileUpload(Thread):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._fb_queue, self._context, self._msg, self._image_queue, self._analyse_type, self._mqtt_list = args
|
self._fb_queue, self._context, self._msg, self._image_queue, self._analyse_type, self._mqtt_list = args
|
||||||
self._storage_source = self._context['service']['storage_source']
|
self._storage_source = self._context['service']['storage_source']
|
||||||
<<<<<<< HEAD
|
|
||||||
self._algStatus = False # 默认关闭
|
self._algStatus = False # 默认关闭
|
||||||
|
|
||||||
# self._algStatus = True # 默认关闭
|
# self._algStatus = True # 默认关闭
|
||||||
|
|
@ -35,17 +34,6 @@ class FileUpload(Thread):
|
||||||
|
|
||||||
# 0521:
|
# 0521:
|
||||||
default_enabled = str(self._msg.get("defaultEnabled", "True")).lower() == "true"
|
default_enabled = str(self._msg.get("defaultEnabled", "True")).lower() == "true"
|
||||||
=======
|
|
||||||
self._algStatus = False # 默认关闭
|
|
||||||
|
|
||||||
# self._algStatus = True # 默认关闭
|
|
||||||
self._algSwitch = self._context['service']['algSwitch']
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#0521:
|
|
||||||
default_enabled = str(self._msg.get("defaultEnabled", "True")).lower() == "true"
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
if default_enabled:
|
if default_enabled:
|
||||||
print("执行默认程序(defaultEnabled=True)")
|
print("执行默认程序(defaultEnabled=True)")
|
||||||
self._algSwitch = True
|
self._algSwitch = True
|
||||||
|
|
@ -55,17 +43,10 @@ class FileUpload(Thread):
|
||||||
# 这里放非默认逻辑的代码
|
# 这里放非默认逻辑的代码
|
||||||
self._algSwitch = False
|
self._algSwitch = False
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
print("---line46 :FileUploadThread.py---", self._algSwitch)
|
print("---line46 :FileUploadThread.py---", self._algSwitch)
|
||||||
|
|
||||||
|
|
||||||
# 如果任务是在线、离线处理,则用此类
|
# 如果任务是在线、离线处理,则用此类
|
||||||
=======
|
|
||||||
print("---line46 :FileUploadThread.py---",self._algSwitch)
|
|
||||||
|
|
||||||
|
|
||||||
#如果任务是在线、离线处理,则用此类
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
class ImageFileUpload(FileUpload):
|
class ImageFileUpload(FileUpload):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
|
|
@ -85,10 +66,6 @@ class ImageFileUpload(FileUpload):
|
||||||
'''
|
'''
|
||||||
print('*' * 100, ' mqtt_list:', len(self._mqtt_list))
|
print('*' * 100, ' mqtt_list:', len(self._mqtt_list))
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
model_info = []
|
model_info = []
|
||||||
# 更加模型编码解析数据
|
# 更加模型编码解析数据
|
||||||
for code, det_list in det_xywh.items():
|
for code, det_list in det_xywh.items():
|
||||||
|
|
@ -99,19 +76,10 @@ class ImageFileUpload(FileUpload):
|
||||||
for target in target_list:
|
for target in target_list:
|
||||||
# 自研车牌模型判断
|
# 自研车牌模型判断
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
<<<<<<< HEAD
|
|
||||||
draw_name_ocr(target[1], aFrame, target[4])
|
draw_name_ocr(target[1], aFrame, target[4])
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
draw_name_crowd(target[1], aFrame, target[4])
|
draw_name_crowd(target[1], aFrame, target[4])
|
||||||
=======
|
|
||||||
box = [target[1][0][0], target[1][0][1], target[1][3][0], target[1][3][1]]
|
|
||||||
draw_name_ocr(box, aFrame, target[4], target[0])
|
|
||||||
cls = 0
|
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
draw_name_crowd(target[3], aFrame, target[4], cls)
|
|
||||||
cls = 0
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
else:
|
else:
|
||||||
draw_painting_joint(target[1], aFrame, target[3], target[2], target[4], font_config,
|
draw_painting_joint(target[1], aFrame, target[3], target[2], target[4], font_config,
|
||||||
target[5])
|
target[5])
|
||||||
|
|
@ -171,15 +139,10 @@ class ImageFileUpload(FileUpload):
|
||||||
if 'stop' == image_msg[1]:
|
if 'stop' == image_msg[1]:
|
||||||
logger.info("开始停止图片上传线程, requestId:{}", request_id)
|
logger.info("开始停止图片上传线程, requestId:{}", request_id)
|
||||||
break
|
break
|
||||||
<<<<<<< HEAD
|
|
||||||
if 'algStart' == image_msg[1]: self._algStatus = True; logger.info(
|
if 'algStart' == image_msg[1]: self._algStatus = True; logger.info(
|
||||||
"图片上传线程,执行算法开启命令, requestId:{}", request_id)
|
"图片上传线程,执行算法开启命令, requestId:{}", request_id)
|
||||||
if 'algStop' == image_msg[1]: self._algStatus = False; logger.info(
|
if 'algStop' == image_msg[1]: self._algStatus = False; logger.info(
|
||||||
"图片上传线程,执行算法关闭命令, requestId:{}", request_id)
|
"图片上传线程,执行算法关闭命令, requestId:{}", request_id)
|
||||||
=======
|
|
||||||
if 'algStart' == image_msg[1]: self._algStatus = True; logger.info("图片上传线程,执行算法开启命令, requestId:{}", request_id)
|
|
||||||
if 'algStop' == image_msg[1]: self._algStatus = False; logger.info("图片上传线程,执行算法关闭命令, requestId:{}", request_id)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
if image_msg[0] == 1:
|
if image_msg[0] == 1:
|
||||||
image_result = self.handle_image(image_msg[1], frame_step)
|
image_result = self.handle_image(image_msg[1], frame_step)
|
||||||
|
|
@ -190,13 +153,8 @@ class ImageFileUpload(FileUpload):
|
||||||
image_result["last_frame"],
|
image_result["last_frame"],
|
||||||
analyse_type,
|
analyse_type,
|
||||||
"OR", "0", "0", request_id)
|
"OR", "0", "0", request_id)
|
||||||
<<<<<<< HEAD
|
|
||||||
if self._storage_source == 1:
|
if self._storage_source == 1:
|
||||||
or_future = t.submit(minioSdk.put_object, or_image, or_image_name)
|
or_future = t.submit(minioSdk.put_object, or_image, or_image_name)
|
||||||
=======
|
|
||||||
if self._storage_source==1:
|
|
||||||
or_future = t.submit(minioSdk.put_object, or_image,or_image_name)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
else:
|
else:
|
||||||
or_future = t.submit(aliyunOssSdk.put_object, or_image_name, or_image.tobytes())
|
or_future = t.submit(aliyunOssSdk.put_object, or_image_name, or_image.tobytes())
|
||||||
task.append(or_future)
|
task.append(or_future)
|
||||||
|
|
@ -211,20 +169,12 @@ class ImageFileUpload(FileUpload):
|
||||||
model_info["modelCode"],
|
model_info["modelCode"],
|
||||||
model_info["detectTargetCode"],
|
model_info["detectTargetCode"],
|
||||||
request_id)
|
request_id)
|
||||||
<<<<<<< HEAD
|
|
||||||
if self._storage_source == 1:
|
if self._storage_source == 1:
|
||||||
=======
|
|
||||||
if self._storage_source==1:
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
ai_future = t.submit(minioSdk.put_object, ai_image,
|
ai_future = t.submit(minioSdk.put_object, ai_image,
|
||||||
ai_image_name)
|
ai_image_name)
|
||||||
else:
|
else:
|
||||||
ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name,
|
ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name,
|
||||||
<<<<<<< HEAD
|
|
||||||
ai_image.tobytes())
|
ai_image.tobytes())
|
||||||
=======
|
|
||||||
ai_image.tobytes())
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
task.append(ai_future)
|
task.append(ai_future)
|
||||||
# msg_list.append(message_feedback(request_id,
|
# msg_list.append(message_feedback(request_id,
|
||||||
|
|
@ -248,15 +198,9 @@ class ImageFileUpload(FileUpload):
|
||||||
model_info['detectTargetCode'],
|
model_info['detectTargetCode'],
|
||||||
longitude=model_info['gps'][0],
|
longitude=model_info['gps'][0],
|
||||||
latitude=model_info['gps'][1],
|
latitude=model_info['gps'][1],
|
||||||
<<<<<<< HEAD
|
|
||||||
))
|
))
|
||||||
|
|
||||||
if (not self._algSwitch) or (self._algStatus and self._algSwitch):
|
if (not self._algSwitch) or (self._algStatus and self._algSwitch):
|
||||||
=======
|
|
||||||
) )
|
|
||||||
|
|
||||||
if (not self._algSwitch) or ( self._algStatus and self._algSwitch):
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
for msg in msg_list:
|
for msg in msg_list:
|
||||||
put_queue(fb_queue, msg, timeout=2, is_ex=False)
|
put_queue(fb_queue, msg, timeout=2, is_ex=False)
|
||||||
del task, msg_list
|
del task, msg_list
|
||||||
|
|
@ -281,10 +225,6 @@ def build_image_name(*args):
|
||||||
time_now = TimeUtils.now_date_to_str("%Y-%m-%d-%H-%M-%S")
|
time_now = TimeUtils.now_date_to_str("%Y-%m-%d-%H-%M-%S")
|
||||||
return "%s/%s_frame-%s-%s_type_%s-%s-%s-%s_%s.jpg" % (request_id, time_now, current_frame, last_frame,
|
return "%s/%s_frame-%s-%s_type_%s-%s-%s-%s_%s.jpg" % (request_id, time_now, current_frame, last_frame,
|
||||||
random_num, mode_type, modeCode, target, image_type)
|
random_num, mode_type, modeCode, target, image_type)
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
|
|
||||||
# 如果任务是图像处理,则用此类
|
# 如果任务是图像处理,则用此类
|
||||||
|
|
@ -317,16 +257,10 @@ class ImageTypeImageFileUpload(Thread):
|
||||||
for target in target_list:
|
for target in target_list:
|
||||||
# 自研车牌模型判断
|
# 自研车牌模型判断
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
<<<<<<< HEAD
|
|
||||||
draw_name_ocr(target, aiFrame, font_config[cls])
|
draw_name_ocr(target, aiFrame, font_config[cls])
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or \
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or \
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
draw_name_crowd(target, aiFrame, font_config[cls])
|
draw_name_crowd(target, aiFrame, font_config[cls])
|
||||||
=======
|
|
||||||
draw_name_ocr(target[1], aiFrame, font_config[cls], target[0])
|
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
draw_name_crowd(target[1],aiFrame,font_config[cls],target[0])
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
else:
|
else:
|
||||||
draw_painting_joint(target[1], aiFrame, target[3], target[2], target[4], font_config)
|
draw_painting_joint(target[1], aiFrame, target[3], target[2], target[4], font_config)
|
||||||
|
|
||||||
|
|
@ -381,13 +315,8 @@ class ImageTypeImageFileUpload(Thread):
|
||||||
ai_image_name = build_image_name(0, 0, analyse_type, "AI", result.get("modelCode"),
|
ai_image_name = build_image_name(0, 0, analyse_type, "AI", result.get("modelCode"),
|
||||||
result.get("type"), request_id)
|
result.get("type"), request_id)
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if self._storage_source == 1:
|
if self._storage_source == 1:
|
||||||
ai_future = t.submit(minioSdk.put_object, copy_frame, ai_image_name)
|
ai_future = t.submit(minioSdk.put_object, copy_frame, ai_image_name)
|
||||||
=======
|
|
||||||
if self._storage_source==1:
|
|
||||||
ai_future = t.submit(minioSdk.put_object, copy_frame,ai_image_name)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
else:
|
else:
|
||||||
ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name, copy_frame)
|
ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name, copy_frame)
|
||||||
|
|
||||||
|
|
@ -409,21 +338,12 @@ class ImageTypeImageFileUpload(Thread):
|
||||||
if image_url is None:
|
if image_url is None:
|
||||||
or_result, or_image = cv2.imencode(".jpg", image_result.get("or_frame"))
|
or_result, or_image = cv2.imencode(".jpg", image_result.get("or_frame"))
|
||||||
image_url_0 = build_image_name(image_result.get("current_frame"),
|
image_url_0 = build_image_name(image_result.get("current_frame"),
|
||||||
<<<<<<< HEAD
|
|
||||||
image_result.get("last_frame"),
|
image_result.get("last_frame"),
|
||||||
analyse_type,
|
analyse_type,
|
||||||
"OR", "0", "O", request_id)
|
"OR", "0", "O", request_id)
|
||||||
|
|
||||||
if self._storage_source == 1:
|
if self._storage_source == 1:
|
||||||
or_future = t.submit(minioSdk.put_object, or_image, image_url_0)
|
or_future = t.submit(minioSdk.put_object, or_image, image_url_0)
|
||||||
=======
|
|
||||||
image_result.get("last_frame"),
|
|
||||||
analyse_type,
|
|
||||||
"OR", "0", "O", request_id)
|
|
||||||
|
|
||||||
if self._storage_source==1:
|
|
||||||
or_future = t.submit(minioSdk.put_object, or_image,image_url_0)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
else:
|
else:
|
||||||
or_future = t.submit(aliyunOssSdk.put_object, image_url_0,
|
or_future = t.submit(aliyunOssSdk.put_object, image_url_0,
|
||||||
or_image.tobytes())
|
or_image.tobytes())
|
||||||
|
|
@ -439,13 +359,8 @@ class ImageTypeImageFileUpload(Thread):
|
||||||
model_info.get("modelCode"),
|
model_info.get("modelCode"),
|
||||||
model_info.get("detectTargetCode"),
|
model_info.get("detectTargetCode"),
|
||||||
request_id)
|
request_id)
|
||||||
<<<<<<< HEAD
|
|
||||||
if self._storage_source == 1:
|
if self._storage_source == 1:
|
||||||
ai_future = t.submit(minioSdk.put_object, ai_image, ai_image_name)
|
ai_future = t.submit(minioSdk.put_object, ai_image, ai_image_name)
|
||||||
=======
|
|
||||||
if self._storage_source==1:
|
|
||||||
ai_future = t.submit(minioSdk.put_object, ai_image, ai_image_name)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
else:
|
else:
|
||||||
ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name,
|
ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name,
|
||||||
ai_image.tobytes())
|
ai_image.tobytes())
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,6 @@ class IntelligentRecognitionProcess(Process):
|
||||||
hb_thread.start()
|
hb_thread.start()
|
||||||
return hb_thread
|
return hb_thread
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
|
|
||||||
class OnlineIntelligentRecognitionProcess(IntelligentRecognitionProcess):
|
class OnlineIntelligentRecognitionProcess(IntelligentRecognitionProcess):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
@ -300,12 +295,8 @@ class OnlineIntelligentRecognitionProcess(IntelligentRecognitionProcess):
|
||||||
for i, model in enumerate(model_array):
|
for i, model in enumerate(model_array):
|
||||||
model_conf, code = model
|
model_conf, code = model
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
||||||
<<<<<<< HEAD
|
|
||||||
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
=======
|
|
||||||
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
if draw_config.get(code) is None:
|
if draw_config.get(code) is None:
|
||||||
draw_config[code] = {}
|
draw_config[code] = {}
|
||||||
draw_config["font_config"] = model_conf[4]
|
draw_config["font_config"] = model_conf[4]
|
||||||
|
|
@ -452,12 +443,12 @@ class OnlineIntelligentRecognitionProcess(IntelligentRecognitionProcess):
|
||||||
class OfflineIntelligentRecognitionProcess(IntelligentRecognitionProcess):
|
class OfflineIntelligentRecognitionProcess(IntelligentRecognitionProcess):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def upload_video(self,base_dir, env, request_id, aiFilePath):
|
def upload_video(self, base_dir, env, request_id, aiFilePath):
|
||||||
aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id)
|
aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id)
|
||||||
upload_video_thread_ai = Common(aliyunVodSdk.get_play_url, aiFilePath, "ai_online_%s" % request_id)
|
upload_video_thread_ai = Common(aliyunVodSdk.get_play_url, aiFilePath, "ai_online_%s" % request_id)
|
||||||
|
|
||||||
if self._storage_source==1:
|
if self._storage_source == 1:
|
||||||
minioSdk = MinioSdk(base_dir, env, request_id )
|
minioSdk = MinioSdk(base_dir, env, request_id)
|
||||||
upload_video_thread_ai = Common(minioSdk.put_object, aiFilePath, "ai_online_%s.mp4" % request_id)
|
upload_video_thread_ai = Common(minioSdk.put_object, aiFilePath, "ai_online_%s.mp4" % request_id)
|
||||||
else:
|
else:
|
||||||
aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id)
|
aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id)
|
||||||
|
|
@ -631,12 +622,8 @@ class OfflineIntelligentRecognitionProcess(IntelligentRecognitionProcess):
|
||||||
for i, model in enumerate(model_array):
|
for i, model in enumerate(model_array):
|
||||||
model_conf, code = model
|
model_conf, code = model
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
||||||
<<<<<<< HEAD
|
|
||||||
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
=======
|
|
||||||
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
if draw_config.get(code) is None:
|
if draw_config.get(code) is None:
|
||||||
draw_config[code] = {}
|
draw_config[code] = {}
|
||||||
draw_config["font_config"] = model_conf[4]
|
draw_config["font_config"] = model_conf[4]
|
||||||
|
|
@ -953,11 +940,7 @@ class PhotosIntelligentRecognitionProcess(Process):
|
||||||
logger.error("模型分析异常: {}, requestId: {}", format_exc(), request_id)
|
logger.error("模型分析异常: {}, requestId: {}", format_exc(), request_id)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
<<<<<<< HEAD
|
# 自研究车牌模型
|
||||||
#自研车牌模型
|
|
||||||
=======
|
|
||||||
#自研究车牌模型
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
def carplate_rec(self, imageUrl, mod, image_queue, request_id):
|
def carplate_rec(self, imageUrl, mod, image_queue, request_id):
|
||||||
try:
|
try:
|
||||||
# model_conf: modeType, allowedList, detpar, ocrmodel, rainbows
|
# model_conf: modeType, allowedList, detpar, ocrmodel, rainbows
|
||||||
|
|
@ -996,10 +979,6 @@ class PhotosIntelligentRecognitionProcess(Process):
|
||||||
# param = [image, new_device, model, par, img_type, request_id]
|
# param = [image, new_device, model, par, img_type, request_id]
|
||||||
# model_conf, frame, device, requestId
|
# model_conf, frame, device, requestId
|
||||||
dataBack = MODEL_CONFIG[code][3]([[modeType, device, model, postPar], image, request_id])[0][2]
|
dataBack = MODEL_CONFIG[code][3]([[modeType, device, model, postPar], image, request_id])[0][2]
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
logger.info("当前人数:{}", dataBack[0][0])
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
dets[code][0] = dataBack
|
dets[code][0] = dataBack
|
||||||
if not dataBack:
|
if not dataBack:
|
||||||
logger.info("当前页面无人")
|
logger.info("当前页面无人")
|
||||||
|
|
@ -1288,12 +1267,8 @@ class PhotosIntelligentRecognitionProcess(Process):
|
||||||
result = t.submit(self.carpalteRec, imageUrls, model, image_queue, request_id)
|
result = t.submit(self.carpalteRec, imageUrls, model, image_queue, request_id)
|
||||||
task_list.append(result)
|
task_list.append(result)
|
||||||
# 人群计数模型
|
# 人群计数模型
|
||||||
<<<<<<< HEAD
|
|
||||||
elif model[1] == ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] or \
|
elif model[1] == ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] or \
|
||||||
model[1] == ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1]:
|
model[1] == ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1]:
|
||||||
=======
|
|
||||||
elif model[1] == ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1]:
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
result = t.submit(self.denscrowdcountRec, imageUrls, model, image_queue, request_id)
|
result = t.submit(self.denscrowdcountRec, imageUrls, model, image_queue, request_id)
|
||||||
task_list.append(result)
|
task_list.append(result)
|
||||||
else:
|
else:
|
||||||
|
|
@ -1508,15 +1483,9 @@ class ScreenRecordingProcess(Process):
|
||||||
clear_queue(self._hb_queue)
|
clear_queue(self._hb_queue)
|
||||||
clear_queue(self._pull_queue)
|
clear_queue(self._pull_queue)
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
def upload_video(self, base_dir, env, request_id, orFilePath):
|
def upload_video(self, base_dir, env, request_id, orFilePath):
|
||||||
if self._storage_source == 1:
|
if self._storage_source == 1:
|
||||||
minioSdk = MinioSdk(base_dir, env, request_id)
|
minioSdk = MinioSdk(base_dir, env, request_id)
|
||||||
=======
|
|
||||||
def upload_video(self,base_dir, env, request_id, orFilePath):
|
|
||||||
if self._storage_source==1:
|
|
||||||
minioSdk = MinioSdk(base_dir, env, request_id )
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
upload_video_thread_ai = Common(minioSdk.put_object, aiFilePath, "%s/ai_online.mp4" % request_id)
|
upload_video_thread_ai = Common(minioSdk.put_object, aiFilePath, "%s/ai_online.mp4" % request_id)
|
||||||
else:
|
else:
|
||||||
aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id)
|
aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id)
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,6 @@ class OnPushStreamProcess(PushStreamProcess):
|
||||||
# 自研车牌模型处理
|
# 自研车牌模型处理
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
cls = 0
|
cls = 0
|
||||||
<<<<<<< HEAD
|
|
||||||
box = xy2xyxy(qs[1])
|
box = xy2xyxy(qs[1])
|
||||||
score = None
|
score = None
|
||||||
color = rainbows[cls]
|
color = rainbows[cls]
|
||||||
|
|
@ -160,22 +159,11 @@ class OnPushStreamProcess(PushStreamProcess):
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
cls = 0
|
cls = 0
|
||||||
=======
|
# crowdlabel, points = qs
|
||||||
ocrlabel, xybox = qs
|
|
||||||
box = xy2xyxy(xybox)
|
|
||||||
score = None
|
|
||||||
color = rainbows[cls]
|
|
||||||
label_array = None
|
|
||||||
rr = t.submit(draw_name_ocr, xybox, copy_frame, color, ocrlabel)
|
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
cls = 0
|
|
||||||
crowdlabel, points = qs
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
box = [(0, 0), (0, 0), (0, 0), (0, 0)]
|
box = [(0, 0), (0, 0), (0, 0), (0, 0)]
|
||||||
score = None
|
score = None
|
||||||
color = rainbows[cls]
|
color = rainbows[cls]
|
||||||
label_array = None
|
label_array = None
|
||||||
<<<<<<< HEAD
|
|
||||||
rr = t.submit(draw_name_crowd, qs, copy_frame, color)
|
rr = t.submit(draw_name_crowd, qs, copy_frame, color)
|
||||||
else:
|
else:
|
||||||
try: # 应对NaN情况
|
try: # 应对NaN情况
|
||||||
|
|
@ -192,24 +180,6 @@ class OnPushStreamProcess(PushStreamProcess):
|
||||||
else:
|
else:
|
||||||
rr = t.submit(draw_painting_joint, box, copy_frame, label_array,
|
rr = t.submit(draw_painting_joint, box, copy_frame, label_array,
|
||||||
score, color, font_config)
|
score, color, font_config)
|
||||||
=======
|
|
||||||
rr = t.submit(draw_name_crowd, points, copy_frame, color, crowdlabel)
|
|
||||||
else:
|
|
||||||
try: # 应对NaN情况
|
|
||||||
box, score, cls = xywh2xyxy2(qs)
|
|
||||||
except:
|
|
||||||
continue
|
|
||||||
if cls not in allowedList or score < frame_score:
|
|
||||||
continue
|
|
||||||
label_array, color = label_arrays[cls], rainbows[cls]
|
|
||||||
if ModelType.CHANNEL2_MODEL.value[1] == str(code) and cls == 2:
|
|
||||||
rr = t.submit(draw_name_joint, box, copy_frame,
|
|
||||||
draw_config[code]["label_dict"], score, color,
|
|
||||||
font_config, qs[6])
|
|
||||||
else:
|
|
||||||
rr = t.submit(draw_painting_joint, box, copy_frame, label_array,
|
|
||||||
score, color, font_config)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
thread_p.append(rr)
|
thread_p.append(rr)
|
||||||
if det_xywh.get(code) is None:
|
if det_xywh.get(code) is None:
|
||||||
|
|
@ -291,24 +261,18 @@ class OnPushStreamProcess(PushStreamProcess):
|
||||||
is_new = False
|
is_new = False
|
||||||
if q[11] == 1:
|
if q[11] == 1:
|
||||||
is_new = True
|
is_new = True
|
||||||
<<<<<<< HEAD
|
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
||||||
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
box = qs
|
box = qs
|
||||||
=======
|
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
|
||||||
cls = ocrlabel
|
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
cls = crowdlabel
|
|
||||||
label_array = points
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
if cd is None:
|
if cd is None:
|
||||||
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
||||||
else:
|
else:
|
||||||
det_xywh2[code][cls].append([cls, box, score, label_array, color, is_new])
|
det_xywh2[code][cls].append(
|
||||||
|
[cls, box, score, label_array, color, is_new])
|
||||||
if len(det_xywh2) > 0:
|
if len(det_xywh2) > 0:
|
||||||
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames, draw_config["font_config"]]))
|
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames,
|
||||||
|
draw_config["font_config"]]))
|
||||||
|
|
||||||
push_p = push_stream_result.result(timeout=60)
|
push_p = push_stream_result.result(timeout=60)
|
||||||
ai_video_file = write_ai_video_result.result(timeout=60)
|
ai_video_file = write_ai_video_result.result(timeout=60)
|
||||||
|
|
@ -430,38 +394,21 @@ class OffPushStreamProcess(PushStreamProcess):
|
||||||
# 自研车牌模型处理
|
# 自研车牌模型处理
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
cls = 0
|
cls = 0
|
||||||
<<<<<<< HEAD
|
|
||||||
box = xy2xyxy(qs[1])
|
box = xy2xyxy(qs[1])
|
||||||
=======
|
|
||||||
ocrlabel, xybox = qs
|
|
||||||
box = xy2xyxy(xybox)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
score = None
|
score = None
|
||||||
color = rainbows[cls]
|
color = rainbows[cls]
|
||||||
label_array = None
|
label_array = None
|
||||||
label_arrays = [None]
|
label_arrays = [None]
|
||||||
<<<<<<< HEAD
|
|
||||||
rr = t.submit(draw_name_ocr, qs, copy_frame, color)
|
rr = t.submit(draw_name_ocr, qs, copy_frame, color)
|
||||||
|
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
cls = 0
|
cls = 0
|
||||||
=======
|
|
||||||
rr = t.submit(draw_name_ocr,xybox,copy_frame,color,ocrlabel)
|
|
||||||
|
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
cls = 0
|
|
||||||
crowdlabel, points = qs
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
box = [(0,0),(0,0),(0,0),(0,0)]
|
box = [(0,0),(0,0),(0,0),(0,0)]
|
||||||
score = None
|
score = None
|
||||||
color = rainbows[cls]
|
color = rainbows[cls]
|
||||||
label_array = None
|
label_array = None
|
||||||
<<<<<<< HEAD
|
|
||||||
rr = t.submit(draw_name_crowd, qs, copy_frame, color)
|
rr = t.submit(draw_name_crowd, qs, copy_frame, color)
|
||||||
=======
|
|
||||||
rr = t.submit(draw_name_crowd, points, copy_frame, color, crowdlabel)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
box, score, cls = xywh2xyxy2(qs)
|
box, score, cls = xywh2xyxy2(qs)
|
||||||
|
|
@ -553,23 +500,15 @@ class OffPushStreamProcess(PushStreamProcess):
|
||||||
if q[11] == 1:
|
if q[11] == 1:
|
||||||
is_new = True
|
is_new = True
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \
|
||||||
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\
|
||||||
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code):
|
||||||
box = qs
|
box = qs
|
||||||
=======
|
|
||||||
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
|
||||||
cls = ocrlabel
|
|
||||||
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
|
||||||
cls = crowdlabel
|
|
||||||
label_array = points
|
|
||||||
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
if cd is None:
|
if cd is None:
|
||||||
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
||||||
else:
|
else:
|
||||||
det_xywh2[code][cls].append([cls, box, score, label_array, color, is_new])
|
det_xywh2[code][cls].append(
|
||||||
|
[cls, box, score, label_array, color, is_new])
|
||||||
if len(det_xywh2) > 0:
|
if len(det_xywh2) > 0:
|
||||||
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames, draw_config["font_config"]]))
|
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames, draw_config["font_config"]]))
|
||||||
push_p = push_stream_result.result(timeout=60)
|
push_p = push_stream_result.result(timeout=60)
|
||||||
|
|
|
||||||
|
|
@ -374,13 +374,8 @@ class ModelType(Enum):
|
||||||
},
|
},
|
||||||
'models':[
|
'models':[
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
'weight':'../weights/trt/AIlib2/cityMangement3/yolov5_%s_fp16.engine'%(gpuName),
|
'weight':'../weights/trt/AIlib2/cityMangement3/yolov5_%s_fp16.engine'%(gpuName),
|
||||||
'name':'yolov5',
|
'name':'yolov5',
|
||||||
=======
|
|
||||||
'weight':'../weights/trt/AIlib2/cityMangement3/yolov5_%s_fp16.engine'%(gpuName),
|
|
||||||
'name':'yolov5',
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
'model':yolov5Model,
|
'model':yolov5Model,
|
||||||
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3,4,5,6,7],'segRegionCnt':1, 'trtFlag_det':True,'trtFlag_seg':True, "score_byClass":{"0":0.8,"1":0.4,"2":0.5,"3":0.5 } }
|
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3,4,5,6,7],'segRegionCnt':1, 'trtFlag_det':True,'trtFlag_seg':True, "score_byClass":{"0":0.8,"1":0.4,"2":0.5,"3":0.5 } }
|
||||||
},
|
},
|
||||||
|
|
@ -979,11 +974,7 @@ class ModelType(Enum):
|
||||||
'row': 2,
|
'row': 2,
|
||||||
'line': 2,
|
'line': 2,
|
||||||
'point_loss_coef': 0.45,
|
'point_loss_coef': 0.45,
|
||||||
<<<<<<< HEAD
|
'conf': 0.65,
|
||||||
'conf': 0.50,
|
|
||||||
=======
|
|
||||||
'conf': 0.25,
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
'gpu_id': 0,
|
'gpu_id': 0,
|
||||||
'eos_coef': '0.5',
|
'eos_coef': '0.5',
|
||||||
'set_cost_class': 1,
|
'set_cost_class': 1,
|
||||||
|
|
@ -1011,7 +1002,6 @@ class ModelType(Enum):
|
||||||
"rainbows": COLOR
|
"rainbows": COLOR
|
||||||
},
|
},
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
})
|
})
|
||||||
|
|
||||||
CITY_UNDERBUILDCOUNT_MODEL = ("30", "306", "建筑物下人群计数", 'perUnderBuild', lambda device, gpuName: {
|
CITY_UNDERBUILDCOUNT_MODEL = ("30", "306", "建筑物下人群计数", 'perUnderBuild', lambda device, gpuName: {
|
||||||
|
|
@ -1046,8 +1036,6 @@ class ModelType(Enum):
|
||||||
'backbone': 'vgg16_bn'
|
'backbone': 'vgg16_bn'
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
=======
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -225,19 +225,11 @@ def draw_name_joint(box, img, label_array_dict, score=0.5, color=None, config=No
|
||||||
cv2.putText(img, label, p3, 0, config[3], [225, 255, 255], thickness=config[4], lineType=cv2.LINE_AA)
|
cv2.putText(img, label, p3, 0, config[3], [225, 255, 255], thickness=config[4], lineType=cv2.LINE_AA)
|
||||||
return img, box
|
return img, box
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
def draw_name_ocr(box, img, color, line_thickness=2, outfontsize=40):
|
def draw_name_ocr(box, img, color, line_thickness=2, outfontsize=40):
|
||||||
font = ImageFont.truetype(FONT_PATH, outfontsize, encoding='utf-8')
|
font = ImageFont.truetype(FONT_PATH, outfontsize, encoding='utf-8')
|
||||||
# (color=None, label=None, font=None, fontSize=40, unify=False)
|
# (color=None, label=None, font=None, fontSize=40, unify=False)
|
||||||
label_zh = get_label_array(color, box[0], font, outfontsize)
|
label_zh = get_label_array(color, box[0], font, outfontsize)
|
||||||
return plot_one_box_auto(box[1], img, color, line_thickness, label_zh)
|
return plot_one_box_auto(box[1], img, color, line_thickness, label_zh)
|
||||||
=======
|
|
||||||
def draw_name_ocr(box, img, color, label, line_thickness=2, outfontsize=40):
|
|
||||||
font = ImageFont.truetype(FONT_PATH, outfontsize, encoding='utf-8')
|
|
||||||
#(color=None, label=None, font=None, fontSize=40, unify=False)
|
|
||||||
label_zh = get_label_array(color, label, font, outfontsize)
|
|
||||||
return plot_one_box_auto(box, img, color, line_thickness, label_zh)
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
def filterBox(det0, det1, pix_dis):
|
def filterBox(det0, det1, pix_dis):
|
||||||
# det0为 (m1, 11) 矩阵
|
# det0为 (m1, 11) 矩阵
|
||||||
|
|
@ -325,7 +317,6 @@ def plot_one_box_auto(box, img, color=None, line_thickness=2, label_array=None):
|
||||||
return img, box
|
return img, box
|
||||||
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
def draw_name_crowd(dets, img, color, line_thickness=2, outfontsize=20):
|
def draw_name_crowd(dets, img, color, line_thickness=2, outfontsize=20):
|
||||||
font = ImageFont.truetype(FONT_PATH, outfontsize, encoding='utf-8')
|
font = ImageFont.truetype(FONT_PATH, outfontsize, encoding='utf-8')
|
||||||
if len(dets) == 1:
|
if len(dets) == 1:
|
||||||
|
|
@ -372,23 +363,6 @@ def draw_name_crowd(dets, img, color, line_thickness=2, outfontsize=20):
|
||||||
|
|
||||||
cv2.polylines(img, [np.asarray(xy2xyxy(b), np.int32)], True, (0, 128, 255), 2)
|
cv2.polylines(img, [np.asarray(xy2xyxy(b), np.int32)], True, (0, 128, 255), 2)
|
||||||
img[y0:y1, x0:x1, :] = label_arr
|
img[y0:y1, x0:x1, :] = label_arr
|
||||||
=======
|
|
||||||
def draw_name_crowd(dets, img, color, label, line_thickness=2, outfontsize=20):
|
|
||||||
font = ImageFont.truetype(FONT_PATH, outfontsize, encoding='utf-8')
|
|
||||||
H,W = img.shape[:2]
|
|
||||||
# img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
|
||||||
# img = Image.fromarray(img)
|
|
||||||
# width, height = img.size
|
|
||||||
Wrate = W // 128 * 128/W
|
|
||||||
Hrate = H // 128 * 128/H
|
|
||||||
|
|
||||||
# img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
|
|
||||||
|
|
||||||
for p in dets:
|
|
||||||
img = cv2.circle(img, (int(p[0]/Wrate), int(p[1]/Hrate)), line_thickness, color, -1)
|
|
||||||
Calc_label_arr = get_label_array(color, label, font, outfontsize)
|
|
||||||
lh, lw = Calc_label_arr.shape[0:2]
|
|
||||||
img[0:lh, 0:lw, :] = Calc_label_arr
|
|
||||||
>>>>>>> origin/zsl
|
|
||||||
|
|
||||||
return img, dets
|
return img, dets
|
||||||
Loading…
Reference in New Issue