更新 concurrency/FileUploadThread.py
This commit is contained in:
parent
1542682828
commit
9f6c1eb8db
|
|
@ -8,12 +8,13 @@ from loguru import logger
|
||||||
import cv2
|
import cv2
|
||||||
from entity.FeedBack import message_feedback
|
from entity.FeedBack import message_feedback
|
||||||
from enums.ExceptionEnum import ExceptionType
|
from enums.ExceptionEnum import ExceptionType
|
||||||
|
from enums.ModelTypeEnum import ModelType
|
||||||
from exception.CustomerException import ServiceException
|
from exception.CustomerException import ServiceException
|
||||||
from util.AliyunSdk import AliyunOssSdk
|
from util.AliyunSdk import AliyunOssSdk
|
||||||
from util.MinioSdk import MinioSdk
|
from util.MinioSdk import MinioSdk
|
||||||
from util import TimeUtils
|
from util import TimeUtils
|
||||||
from enums.AnalysisStatusEnum import AnalysisStatus
|
from enums.AnalysisStatusEnum import AnalysisStatus
|
||||||
from util.PlotsUtils import draw_painting_joint
|
from util.PlotsUtils import draw_painting_joint, draw_name_ocr, draw_name_crowd
|
||||||
from util.QueUtil import put_queue, get_no_block_queue, clear_queue
|
from util.QueUtil import put_queue, get_no_block_queue, clear_queue
|
||||||
import io
|
import io
|
||||||
from util.LocationUtils import locate_byMqtt
|
from util.LocationUtils import locate_byMqtt
|
||||||
|
|
@ -46,14 +47,6 @@ class FileUpload(Thread):
|
||||||
print("---line46 :FileUploadThread.py---",self._algSwitch)
|
print("---line46 :FileUploadThread.py---",self._algSwitch)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#如果任务是在线、离线处理,则用此类
|
#如果任务是在线、离线处理,则用此类
|
||||||
class ImageFileUpload(FileUpload):
|
class ImageFileUpload(FileUpload):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
@ -83,15 +76,27 @@ class ImageFileUpload(FileUpload):
|
||||||
if len(target_list) > 0:
|
if len(target_list) > 0:
|
||||||
aFrame = frame.copy()
|
aFrame = frame.copy()
|
||||||
for target in target_list:
|
for target in target_list:
|
||||||
draw_painting_joint(target[1], aFrame, target[3], target[2], target[4], font_config, target[5])
|
# 自研车牌模型判断
|
||||||
igH,igW = aFrame.shape[0:2]
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
if len(self._mqtt_list)>=1:
|
box = [target[1][0][0], target[1][0][1], target[1][3][0], target[1][3][1]]
|
||||||
#camParas = self._mqtt_list[0]['data']
|
draw_name_ocr(box, aFrame, target[4], target[0])
|
||||||
camParas = self._mqtt_list[0]
|
cls = 0
|
||||||
gps = locate_byMqtt(target[1],igW,igH,camParas,outFormat='wgs84')
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
||||||
|
draw_name_crowd(target[3], aFrame, target[4], cls)
|
||||||
|
cls = 0
|
||||||
else:
|
else:
|
||||||
gps=[None,None]
|
draw_painting_joint(target[1], aFrame, target[3], target[2], target[4], font_config,
|
||||||
model_info.append({"modelCode": str(code), "detectTargetCode": str(cls), "aFrame": aFrame,'gps':gps})
|
target[5])
|
||||||
|
|
||||||
|
igH, igW = aFrame.shape[0:2]
|
||||||
|
if len(self._mqtt_list) >= 1:
|
||||||
|
# camParas = self._mqtt_list[0]['data']
|
||||||
|
camParas = self._mqtt_list[0]
|
||||||
|
gps = locate_byMqtt(target[1], igW, igH, camParas, outFormat='wgs84')
|
||||||
|
else:
|
||||||
|
gps = [None, None]
|
||||||
|
model_info.append(
|
||||||
|
{"modelCode": str(code), "detectTargetCode": str(cls), "aFrame": aFrame, 'gps': gps})
|
||||||
if len(model_info) > 0:
|
if len(model_info) > 0:
|
||||||
image_result = {
|
image_result = {
|
||||||
"or_frame": frame,
|
"or_frame": frame,
|
||||||
|
|
@ -249,12 +254,20 @@ class ImageTypeImageFileUpload(Thread):
|
||||||
if target_list is not None and len(target_list) > 0:
|
if target_list is not None and len(target_list) > 0:
|
||||||
aiFrame = copy_frame.copy()
|
aiFrame = copy_frame.copy()
|
||||||
for target in target_list:
|
for target in target_list:
|
||||||
|
# 自研车牌模型判断
|
||||||
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
|
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])
|
||||||
|
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)
|
||||||
|
|
||||||
model_info.append({
|
model_info.append({
|
||||||
"modelCode": str(code),
|
"modelCode": str(code),
|
||||||
"detectTargetCode": str(cls),
|
"detectTargetCode": str(cls),
|
||||||
"frame": aiFrame
|
"frame": aiFrame
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(model_info) > 0:
|
if len(model_info) > 0:
|
||||||
image_result = {
|
image_result = {
|
||||||
"or_frame": copy_frame,
|
"or_frame": copy_frame,
|
||||||
|
|
@ -363,8 +376,7 @@ class ImageTypeImageFileUpload(Thread):
|
||||||
for thread_result in task:
|
for thread_result in task:
|
||||||
remote_url_list.append(thread_result.result())
|
remote_url_list.append(thread_result.result())
|
||||||
|
|
||||||
|
# 以下代码是为了获取图像上传后,返回的全路径地址
|
||||||
#以下代码是为了获取图像上传后,返回的全路径地址
|
|
||||||
if det_xywh is None:
|
if det_xywh is None:
|
||||||
msg_list.append(message_feedback(request_id,
|
msg_list.append(message_feedback(request_id,
|
||||||
AnalysisStatus.RUNNING.value,
|
AnalysisStatus.RUNNING.value,
|
||||||
|
|
@ -397,10 +409,6 @@ class ImageTypeImageFileUpload(Thread):
|
||||||
model_info_list[ii].get('detectTargetCode'),
|
model_info_list[ii].get('detectTargetCode'),
|
||||||
analyse_results=result))
|
analyse_results=result))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue