result_msg["original_url"] = original_url | result_msg["original_url"] = original_url | ||||
result_msg["sign_url"] = sign_url | result_msg["sign_url"] = sign_url | ||||
result_msg["model_type_code"] = model_type_code | result_msg["model_type_code"] = model_type_code | ||||
result_msg["model_detection_coden"] = model_detection_code | |||||
result_msg["model_detection_code"] = model_detection_code | |||||
result_msg["analyse_time"] = analyse_time | result_msg["analyse_time"] = analyse_time | ||||
results.append(result_msg) | results.append(result_msg) | ||||
taskfb["results"] = results | taskfb["results"] = results |
from enum import Enum, unique | |||||
# 异常枚举 | |||||
@unique | |||||
class ModelType(Enum): | |||||
WATER_SURFACE_MODEL = ("1", "001", "水面模型") | |||||
FOREST_FARM_MODEL = ("2", "002", "林场模型") | |||||
def checkCode(code): | |||||
for model in ModelType: | |||||
if model.value[1] == code: | |||||
return True | |||||
return False |
ExceptionType.OR_VIDEO_ADDRESS_EXCEPTION.value[1]) | ExceptionType.OR_VIDEO_ADDRESS_EXCEPTION.value[1]) | ||||
self.or_video_file = cv2.VideoWriter(self.orFilePath, cv2.VideoWriter_fourcc(*'mp4v'), self.fps, (self.width, self.height)) | self.or_video_file = cv2.VideoWriter(self.orFilePath, cv2.VideoWriter_fourcc(*'mp4v'), self.fps, (self.width, self.height)) | ||||
self.ai_video_file = cv2.VideoWriter(self.aiFilePath, cv2.VideoWriter_fourcc(*'mp4v'), self.fps, (self.width, int(self.height/2))) | |||||
self.ai_video_file = cv2.VideoWriter(self.aiFilePath, cv2.VideoWriter_fourcc(*'mp4v'), self.fps, (self.width * 2, self.height)) | |||||
except ServiceException as s: | except ServiceException as s: | ||||
raise s | raise s | ||||
except Exception as e: | except Exception as e: | ||||
logger.exception(e) | logger.exception(e) | ||||
def video_merge(self, frame1, frame2): | def video_merge(self, frame1, frame2): | ||||
frameLeft = cv2.resize(frame1, (int(self.width / 2), int(self.height / 2)), interpolation=cv2.INTER_LINEAR) | |||||
frameRight = cv2.resize(frame2, (int(self.width / 2), int(self.height / 2)), interpolation=cv2.INTER_LINEAR) | |||||
frameLeft = cv2.resize(frame1, (int(self.width), int(self.height)), interpolation=cv2.INTER_LINEAR) | |||||
frameRight = cv2.resize(frame2, (int(self.width), int(self.height)), interpolation=cv2.INTER_LINEAR) | |||||
frame_merge = np.hstack((frameLeft, frameRight)) | frame_merge = np.hstack((frameLeft, frameRight)) | ||||
return frame_merge | return frame_merge | ||||
self.device = select_device(self.device_) | self.device = select_device(self.device_) | ||||
self.names = get_labelnames(labelnames) | self.names = get_labelnames(labelnames) | ||||
###默认是1920,在森林巡检的高清图像中是4920 | ###默认是1920,在森林巡检的高清图像中是4920 | ||||
imageW = 4915 | |||||
imageW = 1920 | |||||
outfontsize = int(imageW/1920*40) | outfontsize = int(imageW/1920*40) | ||||
self.label_arraylist = get_label_arrays(self.names, self.rainbows, outfontsize=outfontsize, fontpath="../AIlib/conf/platech.ttf") | self.label_arraylist = get_label_arrays(self.names, self.rainbows, outfontsize=outfontsize, fontpath="../AIlib/conf/platech.ttf") | ||||
self.half = self.device.type != 'cpu' # half precision only supported on CUDA | self.half = self.device.type != 'cpu' # half precision only supported on CUDA |
# 从配置文件读取所有配置信息 | # 从配置文件读取所有配置信息 | ||||
def getConfigs(): | def getConfigs(): | ||||
print("开始读取配置文件,获取配置消息:", Constant.APPLICATION_CONFIG) | print("开始读取配置文件,获取配置消息:", Constant.APPLICATION_CONFIG) | ||||
applicationConfigPath = "../dsp_application.yml" | |||||
print(applicationConfigPath) | |||||
applicationConfigPath = os.path.abspath(Constant.APPLICATION_CONFIG) | |||||
if not os.path.exists(applicationConfigPath): | if not os.path.exists(applicationConfigPath): | ||||
raise Exception("未找到配置文件:{}".format(Constant.APPLICATION_CONFIG)) | raise Exception("未找到配置文件:{}".format(Constant.APPLICATION_CONFIG)) | ||||
with open(applicationConfigPath, Constant.R, encoding=Constant.UTF_8) as f: | with open(applicationConfigPath, Constant.R, encoding=Constant.UTF_8) as f: |