Skip to content

deploy/pipeline/pipeline.py 中关于 camera_id 和 rtsp 的几个逻辑问题 #9342

Closed
@Tree-Forever

Description

@Tree-Forever

问题确认 Search before asking

  • 我已经查询历史issue,没有发现相似的bug。I have searched the issues and found no similar bug report.

Bug组件 Bug Component

No response

Bug描述 Describe the Bug

pipeline.py在解析camera_id和rtsp参数,并运行显示时有部分问题

使用的命令如下

python deploy/pipeline/pipeline.py --config deploy/pipeline/config/examples/infer_cfg_human_attr.yml --camera_id=0 --device=gpu

python deploy/pipeline/pipeline.py --config deploy/pipeline/config/examples/infer_cfg_human_attr.yml --rtsp=rtsp://admin:[email protected]:8554/live --device=gpu

问题一:逻辑错误cv2.imshow不会正常显示界面

  1. 在pipeline在_parse_input函数中解析出self.input=0self.input="rtsp://admin:[email protected]:8554/live"

  2. 之后设置 predictor.filename,在set_file_name函数中,使predictor.filename=0if type(path) == int)或predictor.filename=liveelif path is not None 经过os.path分割),并不会在 else 判断里# use camera id
    Image

  3. 而在cv2.imshow的两处代码之前有个判断为if self.file_name is None: # use camera_id

    这个判断会导致cv2.imshow不会正常运行显示

问题二:video_out_nameout_path命名规则在多个rtsp流数据时可能会出现相同命名

当我以下rstsp流时

predictor_item.set_file_name时会使用self.file_name = os.path.split(path)[-1],都会使self.file_name=live,这会导致在命名规则里使用相同self.file_name得到相同的video_out_name,使输出文件路径重复。

问题三:rtsp流获取fps属性,可能不准确

当我使用 IP摄像头app 传输rtsp流数据发现,我设置的帧率为30 FPS Max,通过fps = int(capture.get(cv2.CAP_PROP_FPS))获取到的fps为180000,导致cv2.VideoWriter初始化失败,报错。我查资料发现似乎OpenCV与IP摄像头的RTSP流有可能存在问题,出现未正确传递FPS信息。

在我手动设置fps值后能正常使用

[mpeg4 @ 000001ba830e2180] timebase 1/180000 not supported by MPEG 4 standard, the maximum admitted value for the timebase denominator is 65535
[ERROR:[email protected]] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2822) open Could not open codec mpeg4, error: Unspecified error
[ERROR:[email protected]] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2839) open VIDEOIO/FFMPEG: Failed to initialize VideoWriter

问题四:视频图像队列读取逻辑问题

这个问题在 #7827 就出现过,但是issues里还是很多人出现了。当我使用摄像头长时间未检测到物体时,可能会出现消耗帧的速度比读取摄像头帧的速度快,帧队列被读空,使主线程的循环判断while (not framequeue.empty())提前终止,而capturevideo子线程并未被设置为守护线程,导致主线程结束,而子线程继续持续运行,使进程卡死。

复现环境 Environment

  • OS: Windows
  • PaddlePaddle: 2.6.2
  • PaddleDetection: release/2.8.1
  • Python: 3.10

Bug描述确认 Bug description confirmation

  • 我确认已经提供了Bug复现步骤、代码改动说明、以及环境信息,确认问题是可以复现的。I confirm that the bug replication steps, code change instructions, and environment information have been provided, and the problem can be reproduced.

是否愿意提交PR? Are you willing to submit a PR?

  • 我愿意提交PR!I'd like to help by submitting a PR!

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions