From fdf4d0e3068cd4429124e67f706090d518acd32a Mon Sep 17 00:00:00 2001 From: zhiboniu <31800336+zhiboniu@users.noreply.github.com> Date: Mon, 8 Aug 2022 15:41:18 +0800 Subject: [PATCH] check rtsp stream (#6595) * check rtsp stream * add rtsp in doc s * visual change to false * update rtsp command --- .../pipeline/docs/tutorials/PPHuman_QUICK_STARTED.md | 8 +++++++- .../pipeline/docs/tutorials/PPVehicle_QUICK_STARTED.md | 8 +++++++- deploy/pipeline/pipeline.py | 10 ++++++++-- deploy/pipeline/ppvehicle/vehicle_plate.py | 2 +- deploy/python/visualize.py | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/deploy/pipeline/docs/tutorials/PPHuman_QUICK_STARTED.md b/deploy/pipeline/docs/tutorials/PPHuman_QUICK_STARTED.md index 245db50b6..0e1ddb92c 100644 --- a/deploy/pipeline/docs/tutorials/PPHuman_QUICK_STARTED.md +++ b/deploy/pipeline/docs/tutorials/PPHuman_QUICK_STARTED.md @@ -129,6 +129,12 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_pph python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_pphuman.yml --video_dir=mtmct_dir/ --device=gpu [--run_mode trt_fp16] ``` +对rtsp流的支持,video_file后面的视频地址更换为rtsp流地址,示例如下: +``` +# 行人属性识别,指定配置文件路径和测试视频,在配置文件```deploy/pipeline/config/infer_cfg_pphuman.yml```中的ATTR部分enable设置为```True``` +python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_pphuman.yml -o visual=False --video_file=rtsp://[YOUR_RTSP_SITE] --device=gpu [--run_mode trt_fp16] +``` + ### 参数说明 | 参数 | 是否必须|含义 | @@ -137,7 +143,7 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_pph | --model_dir | Option | PP-Human中各任务模型路径,优先级高于配置文件, 例如`--model_dir det=better_det/ attr=better_attr/`| | --image_file | Option | 需要预测的图片 | | --image_dir | Option | 要预测的图片文件夹路径 | -| --video_file | Option | 需要预测的视频 | +| --video_file | Option | 需要预测的视频,或者rtsp流地址 | | --camera_id | Option | 用来预测的摄像头ID,默认为-1(表示不使用摄像头预测,可设置为:0 - (摄像头数目-1) ),预测过程中在可视化界面按`q`退出输出预测结果到:output/output.mp4| | --device | Option | 运行时的设备,可选择`CPU/GPU/XPU`,默认为`CPU`| | --output_dir | Option|可视化结果保存的根目录,默认为output/| diff --git a/deploy/pipeline/docs/tutorials/PPVehicle_QUICK_STARTED.md b/deploy/pipeline/docs/tutorials/PPVehicle_QUICK_STARTED.md index e559ef308..aa228337a 100644 --- a/deploy/pipeline/docs/tutorials/PPVehicle_QUICK_STARTED.md +++ b/deploy/pipeline/docs/tutorials/PPVehicle_QUICK_STARTED.md @@ -84,6 +84,12 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppv ``` +对rtsp流的支持,video_file后面的视频地址更换为rtsp流地址,示例如下: +``` +# 车辆属性识别,指定配置文件路径和测试视频,在配置文件```deploy/pipeline/config/infer_cfg_ppvehicle.yml```中的ATTR部分enable设置为```True``` +python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppvehicle.yml -o visual=False --video_file=rtsp://[YOUR_RTSP_SITE] --device=gpu [--run_mode trt_fp16] +``` + ### 参数说明 | 参数 | 是否必须|含义 | @@ -92,7 +98,7 @@ python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppv | --model_dir | Option | 各任务模型路径,优先级高于配置文件, 例如`--model_dir det=better_det/ attr=better_attr/`| | --image_file | Option | 需要预测的图片 | | --image_dir | Option | 要预测的图片文件夹路径 | -| --video_file | Option | 需要预测的视频 | +| --video_file | Option | 需要预测的视频,或者rtsp流地址 | | --camera_id | Option | 用来预测的摄像头ID,默认为-1(表示不使用摄像头预测,可设置为:0 - (摄像头数目-1) ),预测过程中在可视化界面按`q`退出输出预测结果到:output/output.mp4| | --device | Option | 运行时的设备,可选择`CPU/GPU/XPU`,默认为`CPU`| | --output_dir | Option|可视化结果保存的根目录,默认为output/| diff --git a/deploy/pipeline/pipeline.py b/deploy/pipeline/pipeline.py index fe3654dae..7683da175 100644 --- a/deploy/pipeline/pipeline.py +++ b/deploy/pipeline/pipeline.py @@ -130,7 +130,9 @@ class Pipeline(object): self.multi_camera = False elif video_file is not None: - assert os.path.exists(video_file), "video_file not exists." + assert os.path.exists( + video_file + ) or 'rtsp' in video_file, "video_file not exists and not an rtsp site." self.multi_camera = False input = video_file self.is_video = True @@ -659,6 +661,8 @@ class PipePredictor(object): # mot -> pose -> action capture = cv2.VideoCapture(video_file) video_out_name = 'output.mp4' if self.file_name is None else self.file_name + if "rtsp" in video_file: + video_out_name = video_out_name + "_rtsp.mp4" # Get Video info : resolution, fps, frame count width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH)) @@ -767,8 +771,10 @@ class PipePredictor(object): if self.with_vehicleplate: if frame_id > self.warmup_frame: self.pipe_timer.module_time['vehicleplate'].start() + plate_input, _, _ = crop_image_with_mot( + frame_rgb, mot_res, expand=False) platelicense = self.vehicleplate_detector.get_platelicense( - crop_input) + plate_input) if frame_id > self.warmup_frame: self.pipe_timer.module_time['vehicleplate'].end() self.pipeline_res.update(platelicense, 'vehicleplate') diff --git a/deploy/pipeline/ppvehicle/vehicle_plate.py b/deploy/pipeline/ppvehicle/vehicle_plate.py index 42e5ba4b0..6a41be6f1 100644 --- a/deploy/pipeline/ppvehicle/vehicle_plate.py +++ b/deploy/pipeline/ppvehicle/vehicle_plate.py @@ -268,7 +268,7 @@ class PlateRecognizer(object): platelicense = "" for text_info in text_pcar: text = text_info[0][0][0] - if len(text) > 2 and text[0] in simcode and len(text) < 10: + if len(text) > 2 and len(text) < 10: platelicense = text plate_all["plate"].append(platelicense) return plate_all diff --git a/deploy/python/visualize.py b/deploy/python/visualize.py index 24aa40796..626da0255 100644 --- a/deploy/python/visualize.py +++ b/deploy/python/visualize.py @@ -418,7 +418,7 @@ def visualize_vehicleplate(im, results, boxes=None): im = np.ascontiguousarray(np.copy(im)) im_h, im_w = im.shape[:2] - text_scale = max(0.5, im.shape[0] / 3000.) + text_scale = max(1.0, im.shape[0] / 1600.) text_thickness = 1 line_inter = im.shape[0] / 40. -- GitLab