ON THIS PAGE

  • Messages
  • Creating a message in Script node
  • Creating a message on the Host

Messages

Messages are sent between linked Nodes. The only way nodes communicate with each other is by sending messages from one to another. On the table of contents (left side of the page) all DepthAI message types are listed under the Messages entry. You can click on them to find out more.

Creating a message in Script node

A DepthAI message can be created either on the device, by a node automatically or manually inside the Script node. In below example, the code is taken from the Script Camera Control example, where the Camera Control message is created inside the Script node every second and sent to the ColorCamera's input (cam.inputControl).
Python
1script = pipeline.create(dai.node.Script)
2script.setScript("""
3  # Create a message
4  ctrl = CameraControl(1)
5  # Configure the message
6  ctrl.setCaptureStill(True)
7  # Send the message from the Script node
8  node.io['out'].send(ctrl)
9""")

Creating a message on the Host

It can also be created on a host computer and sent to the device via XLinkIn node. RGB Camera Control, Video & MobilenetSSD and Stereo Depth from host code examples demonstrate this functionality perfectly. In the example below, we have removed all the code that isn't relevant to showcase how a message can be created on the host and sent to the device via XLink.
Python
1# Create XLinkIn node and configure it
2xin = pipeline.create(dai.node.XLinkIn)
3xin.setStreamName("frameIn")
4xin.out.link(nn.input) # Connect it to NeuralNetwork's input
5
6with dai.Device(pipeline) as device:
7  # Create input queue, which allows you to send messages to the device
8  qIn = device.getInputQueue("frameIn")
9  # Create ImgFrame message
10  img = dai.ImgFrame()
11  img.setData(frame)
12  img.setWidth(300)
13  img.setHeight(300)
14  qIn.send(img) # Send the message to the device