Dot 与 GraphViz 经验总结

论坛 期权论坛 脚本     
匿名技术用户   2020-12-27 06:25   11   0

reference

ubuntu

注:本人仅在ubuntu上进行了测试

安装

  • sudo apt-get install graphviz
    在ubuntu16.04上就这样安装好了,从源码上安装失败,少了scan.c,反正能用,所以不管了。

使用

  • dot -Tjpg example.dot -oexample.jpg
  • example.dot
graph graphname{
a--b;
b--c;
b--d;
d--a;
}
  • 指明输出格式为jpg, -Tjpg, 所有输出格式
  • 指明输出文件名为example.jpg -oexample.jpg
  • example.jpg
    这里写图片描述

An Ugly Tool and A nice Plugin

  • DotEditor: 编辑功能极弱,用法是用别的编辑器进行dot文件编辑,再复制到DotEditor中进行显示。
  • [gedit plugin external tool]:自定义功能极强,可结合gedit 的编辑能力,非常好用。在下面的脚本和图示配置下,按F5即可显示dot图像。
#!/bin/sh
format=jpg
fin=${GEDIT_CURRENT_DOCUMENT_NAME}
fout=${GEDIT_CURRENT_DOCUMENT_NAME}.${format}
touch ${fout}
echo ${fin}
echo ${fout}
dot -T${format} $fin -o${fout} & gnome-open ${fout}

这里写图片描述

High Level Summary

  • for subgraph, the cluster_i(i=0,1,2,…) is special
  • we can use {...} to set local environment
  • set node node [style=filled,color=lightpink];
  • set edge a->b [label='...']
  • use set {a,b,c}->c; a->{b,c,d}
  • set edge direction edge [dir=both/none/forward/back;penwidth=3] , digraph,graph
  • set graph direction rankdir="TB", "LR", "BT", "RL"
  • for dash,solid... see style at 高级API for style,type and other attributes
  • for color node [style=filled,color=lightyellow]; see color gallery
digraph G {

    subgraph Ncluster_0 {
        style=filled;
        color=lightgrey;
        node [style=filled,color=lightgray];
        start -> "motion detection" -> "connected component analysis" -> "small area filter" -> "object feature extraction" -> "object association" -> "association graph" -> "find min tree";
        class -> "IBGS.process()" -> "icvprCcaByTwoPass()" -> "QYzbxTrackingFeature.getObjectsFromMask()" -> "QYzbxTrackingFeature.getObjects()" -> "TrackingObjectAssociation.adjecentObjectAssociation()" -> "TrackingObjectAssociation.process()" -> "MotionBasedTracker.objectTracking()";
        data -> "image:CV_8UC3" -> "mask:CV_8UC1" -> "vector<mask>" -> "vector<ObjectFeature>" -> "list<FrameFeature>" ->"DirectGraph"->"tracking record";
        label="2016/08/20: Connected Component Analysis"
    }

    subgraph Ncluster_1 {
        style=filled
        color=blue
        node [style=filled,color=lightpink];
        "motion detection" -> "contour analysis" -> "kalman filter" -> "hungrian algorithm" -> "trakcking result"
        data -> "image:CV_8UC3" -> "mask:CV_8UC1" -> "contour:vector<Point>" -> "vector<trackingObjectFeature>" -> "MultiObjectTracker:vector<singleObjectTracker>"
        label="2016/08/22: findContour"
    }

    subgraph Ncluster_2 {
        style=filled
        color=red
        node [style=filled,color=lightyellow];
        "motion detection" -> "blob detection" -> "kalman filter" -> "hungrian algorithm" -> "trakcking result"
        data -> "image:CV_8UC3" -> "mask:CV_8UC1" -> "blob feature" -> "vector<trackingObjectFeature>" -> "MultiObjectTracker:vector<singleObjectTracker>"
        label="2016/08/23: blob detector"
    }

}

digraph G{
    {node[style=filled,color=lightyellow]
        input
        "QString:configFile"
        "QString:videoFile"
        "TrackingStatus*:status"
    }

    {node[style=filled,color=lightpink]
        function
        "void:process()"
        "void:processOne()"
        "vector<trackingObjectFeature>:getObjects()"
        "void:Tracking()"
        "void:run()"
        "void:stop()"
    }

    {node[style=filled,color=lightblue]
        explain
        "show tracking result"
        "init singleObjectTracker"
        "update singleObjectTracker"
    }

    {"QString:configFile","QString:videoFile"}->"void:process()"
    "void:process()"->{"Mat:img_input","Mat:img_foreground","Mat:img_background"}
    "void:process()"->"void:processOne()"->"vector<trackingObjectFeature>:getObjects()"->"vector<trackingObjectFeature>"->"void:Tracking()"
    "void:Tracking()"->"init singleObjectTracker"->"update singleObjectTracker"[label="kalman and hungrian"]
    "void:processOne()"->"show tracking result"
    "void:process()"->"void:run()"

    {"Mat:img_input","Mat:img_foreground","Mat:img_background","TrackingStatus*:status"}->"void:processOne()"

    {edge [dir=both;penwidth=3]
        "TrackingStatus*:status"->"TrackingStatus*:globalTrackingStatus"[label="always equal to"]
        {"TrackingStatus*:globalTrackingStatus","bool:globalStop"}->"void:run()"
        "void:process()"->"TrackingStatus*:status"
    }

    "void:stop()"->"bool:globalStop"
}
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP