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 messages 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 CameraControl is created inside the Script node every second and sent to the ColorCamera’s input (cam.inputControl).

script = pipeline.create(dai.node.Script)
   # Create a message
   ctrl = CameraControl()
   # Configure the message
   # Send the message from the Script node['out'].send(ctrl)

Creating a message on a 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.

# Create XLinkIn node and configure it
xin = pipeline.create(dai.node.XLinkIn)
xin.setStreamName("frameIn") # Connect it to NeuralNetwork's input

with dai.Device(pipeline) as device:
   # Create input queue, which allows you to send messages to the device
   qIn = device.getInputQueue("frameIn")
   # Create ImgFrame message
   img = dai.ImgFrame()
   qIn.send(img) # Send the message to the device

Creating a message on an external MCU

A message can also be created on an external MCU and sent to the device via SPIIn node. An demo of such functionality is the spi_in_landmark example.

Got questions?

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