Software Stack
DepthAI
  • DepthAI Components
    • AprilTags
    • Benchmark
    • Camera
    • DetectionNetwork
    • EdgeDetector
    • Events
    • FeatureTracker
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • Misc
    • Modelzoo
    • NeuralNetwork
    • RecordReplay
    • RGBD
    • Script
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • Sync
    • SystemLogger
    • VideoEncoder
    • Visualizer
    • Warp
    • RVC2-specific
  • Advanced Tutorials
  • API Reference
  • Tools

ON THIS PAGE

  • Script Simple
  • Setup
  • Pipeline
  • Source code

Script Simple

This example showcases how to setup the Script node.

Setup

This example requires the DepthAI v3 API, see installation instructions.

Pipeline

Source code

Python
C++

Python

Python
GitHub
1import depthai as dai
2import time
3
4# Create pipeline
5pipeline = dai.Pipeline()
6script = pipeline.create(dai.node.Script)
7inputQueue = script.inputs["in"].createInputQueue()
8outputQueue = script.outputs["out"].createOutputQueue()
9
10
11script.setScript(
12    """
13    while True:
14        message = node.inputs["in"].get()
15        # Or alternatively:
16        # message = node.io["in"].get()
17        node.warn("I received a message!")
18        node.outputs["out"].send(message)
19        # Or alternatively:
20        # node.io["out"].send(message)
21"""
22)
23
24pipeline.start()
25with pipeline:
26    while pipeline.isRunning():
27        message = dai.ImgFrame()
28        print("Sending a message")
29        inputQueue.send(message)
30        output = outputQueue.get()
31        print("Received a message")
32        time.sleep(1)

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.