2、Gstreamer生成pipeline流圖


一、使用命令行

1、安裝dot

 sudo apt-get install graphviz

2、添加到環境變量,文件夾路徑可以隨意改變

export GST_DEBUG_DUMP_DOT_DIR=/home/hiccup/gst_pipeline

3、運行管道

gst-launch-1.0 v4l2src device="/dev/video0" ! "video/x-raw, width=640, height=480, format=(string)YUY2" ! xvimagesink -e

管道結束后,您可以看到.dot生成的文件,並且“* PLAYING_PAUSED *”通常用於生成圖表。

$  ls /tmp 
0.00.00.238129310-gst-launch.NULL_READY.dot
0.00.00.247064574-gst-launch.READY_PAUSED.dot
0.00.00.632677398-gst-launch.PAUSED_PLAYING.dot
0.00.05.464861472-gst-launch.PLAYING_PAUSED.dot
0.00.05.484623147-gst-launch.PAUSED_READY.dot

4、使用dot 生成png圖片

dot -Tpng 0.00.05.464861472-gst-launch.PLAYING_PAUSED.dot > aa.png

pipeline構件圖

  • 橘黃色:src element 和 src pad
  • 紫色:sink element 和 sink pad
  • 綠色:一般的element(除src element 和sink element外)

二、在應用程序中使用(C)

GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");
// 或者
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");

運行應用程序時前綴加上GST_DEBUG_DUMP_DOT_DIR=/home/hiccup/gst_pipeline

GST_DEBUG_DUMP_DOT_DIR=/home/hiccup/gst_pipeline ./application [參數1] [參數2] ...

三、在應用程序中使用(python)
首先安裝依賴:sudo apt-get install graphviz。
1、在你要運行的py文件import的部分添加:

import os
os.environ["GST_DEBUG_DUMP_DOT_DIR"] = "/tmp"
os.putenv('GST_DEBUG_DUMP_DIR_DIR', '/tmp')

最后,在文件中快開始允許loop之前添加Gst.debug_bin_to_dot_file(pipeline, Gst.DebugGraphDetails.ALL, "pipeline")

osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, osd_sink_pad_buffer_probe, 0)

Gst.debug_bin_to_dot_file(pipeline, Gst.DebugGraphDetails.ALL, "pipeline")

# start play back and listen to events
print("Starting pipeline \n")
pipeline.set_state(Gst.State.PLAYING)
try:
    loop.run()
except:
    pass
# cleanup
pipeline.set_state(Gst.State.NULL)

然后就跟上面的操作差不多了,使用dot命令轉化為png即可
參考:
https://forums.developer.nvidia.com/t/python-deepstream-program-not-generating-dot-file/163837


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM