From b75a74d52c9d3a896b8afd82827d35074e944a86 Mon Sep 17 00:00:00 2001 From: th Date: Fri, 25 Jul 2025 18:47:32 +0800 Subject: [PATCH] =?UTF-8?q?1)=E6=96=B0=E5=A2=9EM027:=E5=BB=BA=E7=AD=91?= =?UTF-8?q?=E7=89=A9=E4=B8=8B=E8=A1=8C=E4=BA=BA=E6=A3=80=E6=B5=8B=E5=8F=8A?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=202)=E5=AF=86=E9=9B=86=E4=BA=BA=E7=BE=A4?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E6=A8=A1=E5=9E=8B=E5=8F=8A=E8=87=AA=E7=A0=94?= =?UTF-8?q?=E8=BD=A6=E7=89=8C=E6=A8=A1=E5=9E=8B=E4=BC=98=E5=8C=96=203)?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E6=A8=A1=E5=9E=8B=E6=94=AF=E6=8C=81pt?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=8A=A0=E8=BD=BD=EF=BC=88=E5=B7=B4=E4=B8=AD?= =?UTF-8?q?=E6=B0=B4=E5=88=A9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- concurrency/FileUploadThread.py | 85 -------------------- concurrency/IntelligentRecognitionProcess.py | 39 +-------- concurrency/PushVideoStreamProcess.py | 77 ++---------------- enums/ModelTypeEnum.py | 14 +--- util/PlotsUtils.py | 26 ------ 5 files changed, 13 insertions(+), 228 deletions(-) diff --git a/concurrency/FileUploadThread.py b/concurrency/FileUploadThread.py index 0a49de6..1be5139 100644 --- a/concurrency/FileUploadThread.py +++ b/concurrency/FileUploadThread.py @@ -27,7 +27,6 @@ class FileUpload(Thread): super().__init__() 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'] -<<<<<<< HEAD self._algStatus = False # 默认关闭 # self._algStatus = True # 默认关闭 @@ -35,17 +34,6 @@ class FileUpload(Thread): # 0521: 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: print("执行默认程序(defaultEnabled=True)") self._algSwitch = True @@ -55,17 +43,10 @@ class FileUpload(Thread): # 这里放非默认逻辑的代码 self._algSwitch = False -<<<<<<< HEAD print("---line46 :FileUploadThread.py---", self._algSwitch) # 如果任务是在线、离线处理,则用此类 -======= - print("---line46 :FileUploadThread.py---",self._algSwitch) - - -#如果任务是在线、离线处理,则用此类 ->>>>>>> origin/zsl class ImageFileUpload(FileUpload): __slots__ = () @@ -85,10 +66,6 @@ class ImageFileUpload(FileUpload): ''' print('*' * 100, ' mqtt_list:', len(self._mqtt_list)) -<<<<<<< HEAD -======= - ->>>>>>> origin/zsl model_info = [] # 更加模型编码解析数据 for code, det_list in det_xywh.items(): @@ -99,19 +76,10 @@ class ImageFileUpload(FileUpload): for target in target_list: # 自研车牌模型判断 if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code): -<<<<<<< HEAD draw_name_ocr(target[1], aFrame, target[4]) elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\ ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code): 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: draw_painting_joint(target[1], aFrame, target[3], target[2], target[4], font_config, target[5]) @@ -171,15 +139,10 @@ class ImageFileUpload(FileUpload): if 'stop' == image_msg[1]: logger.info("开始停止图片上传线程, requestId:{}", request_id) break -<<<<<<< HEAD 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) -======= - 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: image_result = self.handle_image(image_msg[1], frame_step) @@ -190,13 +153,8 @@ class ImageFileUpload(FileUpload): image_result["last_frame"], analyse_type, "OR", "0", "0", request_id) -<<<<<<< HEAD if self._storage_source == 1: 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: or_future = t.submit(aliyunOssSdk.put_object, or_image_name, or_image.tobytes()) task.append(or_future) @@ -211,20 +169,12 @@ class ImageFileUpload(FileUpload): model_info["modelCode"], model_info["detectTargetCode"], request_id) -<<<<<<< HEAD if self._storage_source == 1: -======= - if self._storage_source==1: ->>>>>>> origin/zsl ai_future = t.submit(minioSdk.put_object, ai_image, ai_image_name) else: ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name, -<<<<<<< HEAD ai_image.tobytes()) -======= - ai_image.tobytes()) ->>>>>>> origin/zsl task.append(ai_future) # msg_list.append(message_feedback(request_id, @@ -248,15 +198,9 @@ class ImageFileUpload(FileUpload): model_info['detectTargetCode'], longitude=model_info['gps'][0], 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): ->>>>>>> origin/zsl for msg in msg_list: put_queue(fb_queue, msg, timeout=2, is_ex=False) 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") 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) -<<<<<<< HEAD -======= - ->>>>>>> origin/zsl # 如果任务是图像处理,则用此类 @@ -317,16 +257,10 @@ class ImageTypeImageFileUpload(Thread): for target in target_list: # 自研车牌模型判断 if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code): -<<<<<<< HEAD draw_name_ocr(target, aiFrame, font_config[cls]) elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or \ ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code): 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: 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"), result.get("type"), request_id) -<<<<<<< HEAD if self._storage_source == 1: 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: ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name, copy_frame) @@ -409,21 +338,12 @@ class ImageTypeImageFileUpload(Thread): if image_url is None: or_result, or_image = cv2.imencode(".jpg", image_result.get("or_frame")) image_url_0 = build_image_name(image_result.get("current_frame"), -<<<<<<< HEAD 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) -======= - 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: or_future = t.submit(aliyunOssSdk.put_object, image_url_0, or_image.tobytes()) @@ -439,13 +359,8 @@ class ImageTypeImageFileUpload(Thread): model_info.get("modelCode"), model_info.get("detectTargetCode"), request_id) -<<<<<<< HEAD if self._storage_source == 1: 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: ai_future = t.submit(aliyunOssSdk.put_object, ai_image_name, ai_image.tobytes()) diff --git a/concurrency/IntelligentRecognitionProcess.py b/concurrency/IntelligentRecognitionProcess.py index 6053baa..663878b 100644 --- a/concurrency/IntelligentRecognitionProcess.py +++ b/concurrency/IntelligentRecognitionProcess.py @@ -91,11 +91,6 @@ class IntelligentRecognitionProcess(Process): hb_thread.start() return hb_thread -<<<<<<< HEAD -======= - ->>>>>>> origin/zsl - class OnlineIntelligentRecognitionProcess(IntelligentRecognitionProcess): __slots__ = () @@ -300,12 +295,8 @@ class OnlineIntelligentRecognitionProcess(IntelligentRecognitionProcess): for i, model in enumerate(model_array): model_conf, code = model if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \ -<<<<<<< HEAD ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\ 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: draw_config[code] = {} draw_config["font_config"] = model_conf[4] @@ -452,12 +443,12 @@ class OnlineIntelligentRecognitionProcess(IntelligentRecognitionProcess): class OfflineIntelligentRecognitionProcess(IntelligentRecognitionProcess): __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) upload_video_thread_ai = Common(aliyunVodSdk.get_play_url, aiFilePath, "ai_online_%s" % request_id) - if self._storage_source==1: - minioSdk = MinioSdk(base_dir, env, request_id ) + if self._storage_source == 1: + minioSdk = MinioSdk(base_dir, env, request_id) upload_video_thread_ai = Common(minioSdk.put_object, aiFilePath, "ai_online_%s.mp4" % request_id) else: aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id) @@ -631,12 +622,8 @@ class OfflineIntelligentRecognitionProcess(IntelligentRecognitionProcess): for i, model in enumerate(model_array): model_conf, code = model if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \ -<<<<<<< HEAD ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\ 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: draw_config[code] = {} draw_config["font_config"] = model_conf[4] @@ -953,11 +940,7 @@ class PhotosIntelligentRecognitionProcess(Process): logger.error("模型分析异常: {}, requestId: {}", format_exc(), request_id) raise e -<<<<<<< HEAD - #自研车牌模型 -======= - #自研究车牌模型 ->>>>>>> origin/zsl + # 自研究车牌模型 def carplate_rec(self, imageUrl, mod, image_queue, request_id): try: # model_conf: modeType, allowedList, detpar, ocrmodel, rainbows @@ -996,10 +979,6 @@ class PhotosIntelligentRecognitionProcess(Process): # param = [image, new_device, model, par, img_type, request_id] # model_conf, frame, device, requestId 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 if not dataBack: logger.info("当前页面无人") @@ -1288,12 +1267,8 @@ class PhotosIntelligentRecognitionProcess(Process): result = t.submit(self.carpalteRec, imageUrls, model, image_queue, request_id) task_list.append(result) # 人群计数模型 -<<<<<<< HEAD elif model[1] == ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] or \ 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) task_list.append(result) else: @@ -1508,15 +1483,9 @@ class ScreenRecordingProcess(Process): clear_queue(self._hb_queue) clear_queue(self._pull_queue) -<<<<<<< HEAD def upload_video(self, base_dir, env, request_id, orFilePath): if self._storage_source == 1: 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) else: aliyunVodSdk = ThAliyunVodSdk(base_dir, env, request_id) diff --git a/concurrency/PushVideoStreamProcess.py b/concurrency/PushVideoStreamProcess.py index 2b4ba3e..724f189 100644 --- a/concurrency/PushVideoStreamProcess.py +++ b/concurrency/PushVideoStreamProcess.py @@ -151,7 +151,6 @@ class OnPushStreamProcess(PushStreamProcess): # 自研车牌模型处理 if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code): cls = 0 -<<<<<<< HEAD box = xy2xyxy(qs[1]) score = None color = rainbows[cls] @@ -160,22 +159,11 @@ class OnPushStreamProcess(PushStreamProcess): elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\ ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code): cls = 0 -======= - 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 + # crowdlabel, points = qs box = [(0, 0), (0, 0), (0, 0), (0, 0)] score = None color = rainbows[cls] label_array = None -<<<<<<< HEAD rr = t.submit(draw_name_crowd, qs, copy_frame, color) else: try: # 应对NaN情况 @@ -192,24 +180,6 @@ class OnPushStreamProcess(PushStreamProcess): else: rr = t.submit(draw_painting_joint, box, copy_frame, label_array, 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) if det_xywh.get(code) is None: @@ -291,24 +261,18 @@ class OnPushStreamProcess(PushStreamProcess): is_new = False if q[11] == 1: is_new = True -<<<<<<< HEAD if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \ ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\ ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code): 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: det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]] 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: - 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) 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): cls = 0 -<<<<<<< HEAD box = xy2xyxy(qs[1]) -======= - ocrlabel, xybox = qs - box = xy2xyxy(xybox) ->>>>>>> origin/zsl score = None color = rainbows[cls] label_array = None label_arrays = [None] -<<<<<<< HEAD rr = t.submit(draw_name_ocr, qs, copy_frame, color) elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\ ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code): 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)] score = None color = rainbows[cls] label_array = None -<<<<<<< HEAD rr = t.submit(draw_name_crowd, qs, copy_frame, color) -======= - rr = t.submit(draw_name_crowd, points, copy_frame, color, crowdlabel) ->>>>>>> origin/zsl else: box, score, cls = xywh2xyxy2(qs) @@ -553,23 +500,15 @@ class OffPushStreamProcess(PushStreamProcess): if q[11] == 1: is_new = True -<<<<<<< HEAD if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code) or \ ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code) or\ ModelType.CITY_UNDERBUILDCOUNT_MODEL.value[1] == str(code): 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: - 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: - 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: 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) diff --git a/enums/ModelTypeEnum.py b/enums/ModelTypeEnum.py index 23039ec..afc82ee 100644 --- a/enums/ModelTypeEnum.py +++ b/enums/ModelTypeEnum.py @@ -374,13 +374,8 @@ class ModelType(Enum): }, 'models':[ { -<<<<<<< HEAD 'weight':'../weights/trt/AIlib2/cityMangement3/yolov5_%s_fp16.engine'%(gpuName), 'name':'yolov5', -======= - 'weight':'../weights/trt/AIlib2/cityMangement3/yolov5_%s_fp16.engine'%(gpuName), - 'name':'yolov5', ->>>>>>> origin/zsl '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 } } }, @@ -979,11 +974,7 @@ class ModelType(Enum): 'row': 2, 'line': 2, 'point_loss_coef': 0.45, -<<<<<<< HEAD - 'conf': 0.50, -======= - 'conf': 0.25, ->>>>>>> origin/zsl + 'conf': 0.65, 'gpu_id': 0, 'eos_coef': '0.5', 'set_cost_class': 1, @@ -1011,7 +1002,6 @@ class ModelType(Enum): "rainbows": COLOR }, -<<<<<<< HEAD }) CITY_UNDERBUILDCOUNT_MODEL = ("30", "306", "建筑物下人群计数", 'perUnderBuild', lambda device, gpuName: { @@ -1046,8 +1036,6 @@ class ModelType(Enum): 'backbone': 'vgg16_bn' }, }], -======= ->>>>>>> origin/zsl }) @staticmethod diff --git a/util/PlotsUtils.py b/util/PlotsUtils.py index d66f494..3152b29 100644 --- a/util/PlotsUtils.py +++ b/util/PlotsUtils.py @@ -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) return img, box -<<<<<<< HEAD def draw_name_ocr(box, img, color, 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, box[0], font, outfontsize) 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): # 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 -<<<<<<< HEAD def draw_name_crowd(dets, img, color, line_thickness=2, outfontsize=20): font = ImageFont.truetype(FONT_PATH, outfontsize, encoding='utf-8') 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) 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 \ No newline at end of file