diff --git a/deploy/pipeline/docs/tutorials/pphuman_mot.md b/deploy/pipeline/docs/tutorials/pphuman_mot.md index 6380ffbbd7f68d6feb286a1b4f4f33eebcf473a5..00c35c04d37c38d555c8a625456643dbba4cb5ce 100644 --- a/deploy/pipeline/docs/tutorials/pphuman_mot.md +++ b/deploy/pipeline/docs/tutorials/pphuman_mot.md @@ -76,13 +76,16 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_pph --region_polygon 200 200 400 200 300 400 100 400 ``` **注意:** + - 区域闯入的测试视频必须是静止摄像头拍摄的,镜头不能抖动或移动。 - `--do_break_in_counting`表示是否进行区域出入后计数,不设置即默认为False。 - `--region_type`表示流量计数的区域,当设置`--do_break_in_counting`时仅可选择`custom`,默认是`custom`,表示以用户自定义区域为出入口,同一物体框的下边界中点坐标在相邻两秒内从区域外到区域内,即完成计数加一。 - - `--region_polygon`表示用户自定义区域的多边形的点坐标序列,每两个为一对点坐标(x,y),按顺时针顺序连成一个封闭区域,至少需要3对点也即6个整数,默认值是`[]`,需要用户自行设置点坐标。用户可以运行[此段代码](../../tools/get_video_info.py)获取所测视频的分辨率帧数,以及可以自定义画出自己想要的多边形区域的可视化并自己调整。 + - `--region_polygon`表示用户自定义区域的多边形的点坐标序列,每两个为一对点坐标(x,y),**按顺时针顺序**连成一个**封闭区域**,至少需要3对点也即6个整数,默认值是`[]`,需要用户自行设置点坐标,如是四边形区域,坐标顺序是`左上、右上、右下、左下`。用户可以运行[此段代码](../../tools/get_video_info.py)获取所测视频的分辨率帧数,以及可以自定义画出自己想要的多边形区域的可视化并自己调整。 自定义多边形区域的可视化代码运行如下: ```python python get_video_info.py --video_file=demo.mp4 --region_polygon 200 200 400 200 300 400 100 400 ``` + 快速画出想要的区域的小技巧:先任意取点得到图片,用画图工具打开,鼠标放到想要的区域点上会显示出坐标,记录下来并取整,作为这段可视化代码的region_polygon参数,并再次运行可视化,微调点坐标参数直至满意。 + 测试效果如下: diff --git a/deploy/pipeline/docs/tutorials/ppvehicle_illegal_parking.md b/deploy/pipeline/docs/tutorials/ppvehicle_illegal_parking.md index 8fa4a269fbcbbbf2cf570e6dfc12b55693798fd5..c3f87db6c6b5392d4bb5d2a368596fa559293021 100644 --- a/deploy/pipeline/docs/tutorials/ppvehicle_illegal_parking.md +++ b/deploy/pipeline/docs/tutorials/ppvehicle_illegal_parking.md @@ -55,6 +55,16 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/examples/infe - region_type:非法停车区域类型,custom表示自定义; - region_polygon:自定义非法停车多边形,至少为3个点。 +**注意:** + - 违法停车的测试视频必须是静止摄像头拍摄的,镜头不能抖动或移动。 + - `--region_polygon`表示用户自定义区域的多边形的点坐标序列,每两个为一对点坐标(x,y),**按顺时针顺序**连成一个**封闭区域**,至少需要3对点也即6个整数,默认值是`[]`,需要用户自行设置点坐标,如是四边形区域,坐标顺序是`左上、右上、右下、左下`。用户可以运行[此段代码](../../tools/get_video_info.py)获取所测视频的分辨率帧数,以及可以自定义画出自己想要的多边形区域的可视化并自己调整。 + 自定义多边形区域的可视化代码运行如下: + ```python + python get_video_info.py --video_file=demo.mp4 --region_polygon 200 200 400 200 300 400 100 400 + ``` + 快速画出想要的区域的小技巧:先任意取点得到图片,用画图工具打开,鼠标放到想要的区域点上会显示出坐标,记录下来并取整,作为这段可视化代码的region_polygon参数,并再次运行可视化,微调点坐标参数直至满意。 + + 3. 若修改模型路径,有以下两种方式: - 方法一:```./deploy/pipeline/config/examples/infer_cfg_illegal_parking.yml```下可以配置不同模型路径; diff --git a/deploy/pipeline/docs/tutorials/ppvehicle_mot.md b/deploy/pipeline/docs/tutorials/ppvehicle_mot.md index dafefe4c1543627a5890db6fd0f78cacd9f4af01..73b540d8e79ce6b1defe0bbaca4a5aceed62888a 100644 --- a/deploy/pipeline/docs/tutorials/ppvehicle_mot.md +++ b/deploy/pipeline/docs/tutorials/ppvehicle_mot.md @@ -86,13 +86,16 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppv --region_polygon 200 200 400 200 300 400 100 400 ``` **注意:** + - 区域闯入的测试视频必须是静止摄像头拍摄的,镜头不能抖动或移动。 - `--do_break_in_counting`表示是否进行区域出入后计数,不设置即默认为False。 - `--region_type`表示流量计数的区域,当设置`--do_break_in_counting`时仅可选择`custom`,默认是`custom`,表示以用户自定义区域为出入口,同一物体框的下边界中点坐标在相邻两秒内从区域外到区域内,即完成计数加一。 - - `--region_polygon`表示用户自定义区域的多边形的点坐标序列,每两个为一对点坐标(x,y),按顺时针顺序连成一个封闭区域,至少需要3对点也即6个整数,默认值是`[]`,需要用户自行设置点坐标。用户可以运行[此段代码](../../tools/get_video_info.py)获取所测视频的分辨率帧数,以及可以自定义画出自己想要的多边形区域的可视化并自己调整。 + - `--region_polygon`表示用户自定义区域的多边形的点坐标序列,每两个为一对点坐标(x,y),**按顺时针顺序**连成一个**封闭区域**,至少需要3对点也即6个整数,默认值是`[]`,需要用户自行设置点坐标,如是四边形区域,坐标顺序是`左上、右上、右下、左下`。用户可以运行[此段代码](../../tools/get_video_info.py)获取所测视频的分辨率帧数,以及可以自定义画出自己想要的多边形区域的可视化并自己调整。 自定义多边形区域的可视化代码运行如下: ```python python get_video_info.py --video_file=demo.mp4 --region_polygon 200 200 400 200 300 400 100 400 ``` + 快速画出想要的区域的小技巧:先任意取点得到图片,用画图工具打开,鼠标放到想要的区域点上会显示出坐标,记录下来并取整,作为这段可视化代码的region_polygon参数,并再次运行可视化,微调点坐标参数直至满意。 + 【效果展示】 diff --git a/deploy/pipeline/pipeline.py b/deploy/pipeline/pipeline.py index 3f0b8ce4ac4e9b6ee8f978dfe19987d875a5363a..32346843e95ecd1236423b883bdc18cc3d73b3f5 100644 --- a/deploy/pipeline/pipeline.py +++ b/deploy/pipeline/pipeline.py @@ -626,10 +626,20 @@ class PipePredictor(object): mot_result = (frame_id + 1, boxes[0], scores[0], ids[0]) # single class statistic = flow_statistic( - mot_result, self.secs_interval, self.do_entrance_counting, - self.do_break_in_counting, self.region_type, video_fps, - entrance, id_set, interval_id_set, in_id_list, out_id_list, - prev_center, records) + mot_result, + self.secs_interval, + self.do_entrance_counting, + self.do_break_in_counting, + self.region_type, + video_fps, + entrance, + id_set, + interval_id_set, + in_id_list, + out_id_list, + prev_center, + records, + ids2names=self.mot_predictor.pred_config.labels) records = statistic['records'] if self.illegal_parking_time != -1: diff --git a/deploy/pptracking/python/mot/utils.py b/deploy/pptracking/python/mot/utils.py index d31fe7d17d7cad467f7177c7af0a9e067d572de3..5b871a57b26f5e26ab528bff0aa263f93d983d18 100644 --- a/deploy/pptracking/python/mot/utils.py +++ b/deploy/pptracking/python/mot/utils.py @@ -224,7 +224,7 @@ def flow_statistic(result, prev_center, records, data_type='mot', - num_classes=1): + ids2names=['pedestrian']): # Count in/out number: # Note that 'region_type' should be one of ['horizontal', 'vertical', 'custom'], # 'horizontal' and 'vertical' means entrance is the center line as the entrance when do_entrance_counting, @@ -282,25 +282,27 @@ def flow_statistic(result, frame_id -= 1 x1, y1, w, h = tlwh center_x = min(x1 + w / 2., im_w - 1) - center_down_y = min(y1 + h, im_h - 1) + if ids2names[0] == 'pedestrian': + center_y = min(y1 + h, im_h - 1) + else: + center_y = min(y1 + h / 2, im_h - 1) # counting objects in region of the first frame if frame_id == 1: - if in_quadrangle([center_x, center_down_y], entrance, im_h, - im_w): + if in_quadrangle([center_x, center_y], entrance, im_h, im_w): in_id_list.append(-1) else: - prev_center[track_id] = [center_x, center_down_y] + prev_center[track_id] = [center_x, center_y] else: if track_id in prev_center: if not in_quadrangle(prev_center[track_id], entrance, im_h, im_w) and in_quadrangle( - [center_x, center_down_y], - entrance, im_h, im_w): + [center_x, center_y], entrance, + im_h, im_w): in_id_list.append(track_id) - prev_center[track_id] = [center_x, center_down_y] + prev_center[track_id] = [center_x, center_y] else: - prev_center[track_id] = [center_x, center_down_y] + prev_center[track_id] = [center_x, center_y] # Count totol number, number at a manual-setting interval frame_id, tlwhs, tscores, track_ids = result diff --git a/deploy/pptracking/python/mot_jde_infer.py b/deploy/pptracking/python/mot_jde_infer.py index 0fa63f389ad419729d01c1508a6eeb67f7e594f1..e3a9958f7a79b568d0cb1ba9c649aa0499b21e0b 100644 --- a/deploy/pptracking/python/mot_jde_infer.py +++ b/deploy/pptracking/python/mot_jde_infer.py @@ -393,10 +393,21 @@ class JDE_Detector(Detector): result = (frame_id + 1, online_tlwhs[0], online_scores[0], online_ids[0]) statistic = flow_statistic( - result, self.secs_interval, self.do_entrance_counting, - self.do_break_in_counting, self.region_type, video_fps, - entrance, id_set, interval_id_set, in_id_list, out_id_list, - prev_center, records, data_type, num_classes) + result, + self.secs_interval, + self.do_entrance_counting, + self.do_break_in_counting, + self.region_type, + video_fps, + entrance, + id_set, + interval_id_set, + in_id_list, + out_id_list, + prev_center, + records, + data_type, + ids2names=self.pred_config.labels) records = statistic['records'] fps = 1. / timer.duration diff --git a/deploy/pptracking/python/mot_sde_infer.py b/deploy/pptracking/python/mot_sde_infer.py index 07355a2c444967f1b79489d0888356ea1ab1bc97..d8787ec70efab564ce296f57b82f3933f417d293 100644 --- a/deploy/pptracking/python/mot_sde_infer.py +++ b/deploy/pptracking/python/mot_sde_infer.py @@ -634,10 +634,21 @@ class SDE_Detector(Detector): result = (frame_id + 1, online_tlwhs[0], online_scores[0], online_ids[0]) statistic = flow_statistic( - result, self.secs_interval, self.do_entrance_counting, - self.do_break_in_counting, self.region_type, video_fps, - entrance, id_set, interval_id_set, in_id_list, out_id_list, - prev_center, records, data_type, num_classes) + result, + self.secs_interval, + self.do_entrance_counting, + self.do_break_in_counting, + self.region_type, + video_fps, + entrance, + id_set, + interval_id_set, + in_id_list, + out_id_list, + prev_center, + records, + data_type, + ids2names=self.pred_config.labels) records = statistic['records'] fps = 1. / timer.duration