DepthAI Pipeline Graph
The DepthAI Pipeline Graph tool creates dynamic visualizations of DepthAI pipelines. It's an ideal tool for debugging, providing insights into the pipeline's structure and flow.How It Works
In the DepthAI framework, a pipeline consists of various nodes and connections between them. After defining the pipeline in your code, you typically pass it to the device with:Python
1device.startPipeline(pipeline)
Python
1with dai.Device(pipeline) as device:
DEPTHAI_LEVEL=debug
before running your code, the JSON configuration will be printed to the console:Command Line
1[2022-06-01 16:47:33.721] [debug] Schema dump: {"connections":[{"node1Id":8,"node1Output":"passthroughDepth","node1OutputGroup":"","node2Id":10,"node2Input":"in","node2InputGroup":""},...]
pipeline_graph
tool performs the following steps:- Sets
DEPTHAI_LEVEL=debug
- Executes your code
- Captures the schema dump from the output
- Parses the schema to create a visual graph using a modified version of NodeGraphQt
Installation
To install the tool, run:Command Line
1pip install git+https://github.com/luxonis/depthai_pipeline_graph.git
Command Line
1pip install PySide2
Running the Tool
Once installed, you can use the tool by typing:Command Line
1pipeline_graph -h
run
, from_file
, and load
.Available Actions
- Run: Execute your DepthAI script and generate the pipeline graph in real-time.
Command Line
1pipeline_graph run "python your_script.py"
-dnk
option to allow your script to continue running after the schema has been captured:Command Line
1pipeline_graph run "python your_script.py" -dnk
- From File: Generate a pipeline graph from a log file or JSON schema:
Command Line
1pipeline_graph from_file path/to/your/log_or_json_file
- Load: Load and edit a previously saved pipeline graph:
Command Line
1pipeline_graph load path/to/your/saved_graph.json
Customization Options
Node Naming
By default, nodes are named based on their type (e.g.,ColorCamera (0)
), with an index indicating the order of creation. If there are many nodes of the same type, use the -var
or --use_variable_names
option to replace the index with the variable name from your code for better clarity.Command Line
1pipeline_graph run "python your_script.py" -var
-p
or --pipeline_name
argument to specify another name.Command Line
1pipeline_graph run "python your_script.py" -var -p custom_pipeline_name
Interacting with the Graph
Once the graph is displayed, you can perform several actions to customize it:- Rearrange Nodes: Simply drag and drop the nodes to adjust their layout if the default positioning doesn't suit your needs.
- Rename Nodes: Double-click a node's name to edit it directly.
- Change Node Appearance: Double-click on the node itself (outside the name area) to open a window where you can modify its color and name.
- Context Menu Options: Right-click anywhere on the graph to bring up a menu. From here, you can save the graph as a JSON file, load a previously saved graph, or access other options.