ON THIS PAGE

  • Standalone mode
  • Communication with the camera
  • Converting a demo to standalone mode
  • Flash the bootloader
  • Flash the pipeline
  • DepthAI Application Package (.dap)
  • Clear flash
  • Factory reset

Standalone mode

Standalone mode means that the camera starts the (flashed pipeline) as soon as it gets power, without being connected to any particular host computer. This is useful for applications where camera is stationary and just inspecting the world and providing analytics (eg. people/vehicle counting, LPR, fall detection, etc.)Usually, this mode is also more robust to any instabilities (eg. networking issues, where connection between camera and host computer would drop), as application will restart automatically.Standalone mode is only possible on OAKs that have on-board flash memory, which are currently OAK POE and OAK IOT camera models.Scenarios when standalone mode is particularly useful:
  • People/vehicle/object tracking and counting (People counting demo here). Each camera can do its own counting (inside Script node), and only send final count (eg. every hour) to some server via MQTT/HTTP.
  • License Plate Recognition (LPR) camera (demo here). Each camera does vehicle detection, license plate detection and LPR, and only reports license plate (in string) to a server.
  • Fall detection for elderly people (demo here). Each camera tracks people and checks their poses for any anomalies (eg. person falling down). If anomaly is detected, it sends an alert to a server.
In case you already have a computer on-board (eg. a robot/drone), standalone mode isn't as useful, and adds extra complexity.

Communication with the camera

To "communicate" with the outside world (eg. a server), POE cameras can use Script node to send/receive networking packets (HTTP/TCP/UDP...). Here are a few examples:

Converting a demo to standalone mode

Since there won't be any communication between the host and the device, you first need to remove all XLinkOut and XLinkIn nodes.This means that the device will only communicate with the "outside world" via Script node (GPIO/UART or network protocols if you have OAK POE mode; HTTP/TCP/UDP...).Example: Let's update PoE TCP Streaming oak.py script to standalone mode. We'll remove the dai.Device(pipeline) part, and replace it with Flash the pipeline.
Python
1conn.send(bytes(header, encoding='ascii'))
2                  conn.send(data)
3          except Exception as e:
4              node.warn("Client disconnected")
5      """)
6    -  # Connect to the device (via host computer)
7    -  with dai.Device(pipeline) as device:
8    -      print("Connected")
9    -      while True:
10    -          time.sleep(1)
11    +  # Flash the app to the device
12    +  (f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
13    +  bootloader = dai.DeviceBootloader(bl)
14    +  progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
15    +  bootloader.flash(progress, pipeline)
Now, whenever the device gets power, it will start the application which starts the TCP server. You can connect to it with any TCP client (eg. host.py script) and start receiving the video stream.

Flash the bootloader

To run the application on the camera, a Bootloader is required. Note that bootloader is already flashed on all POE cameras, as it's also required for network booting. To flash the latest bootloader, we suggest using the Device Manager. To view the API code behind it, see Flash Bootloader example code.

Flash the pipeline

After you have standalone Pipeline defined and Bootloader already flashed on the device, you can flash the pipeline to the device, along with its assets (eg. AI models). You can flash the pipeline with the following snippet:
Python
1import depthai as dai
2
3pipeline = dai.Pipeline()
4
5# Define standalone pipeline; add nodes and link them
6# cam = pipeline.create(dai.node.ColorCamera)
7# script = pipeline.create(dai.node.Script)
8# ...
9
10# Flash the pipeline
11(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
12bootloader = dai.DeviceBootloader(bl)
13progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
14bootloader.flash(progress, pipeline)
After successfully flashing the pipeline, it will get started automatically when you power up the device. If you would like to change the flashed pipeline, simply re-flash it again.

DepthAI Application Package (.dap)

Alternatively, you can also flash the pipeline with the Device Manager. For this approach, you will need a Depthai Application Package (.dap), which you can create with the following script:
Python
1import depthai as dai
2
3pipeline = dai.Pipeline()
4
5# Define standalone pipeline; add nodes and link them
6# cam = pipeline.create(dai.node.ColorCamera)
7# script = pipeline.create(dai.node.Script)
8# ...
9
10# Create Depthai Application Package (.dap)
11(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
12bootloader = dai.DeviceBootloader(bl)
13bootloader.saveDepthaiApplicationPackage(pipeline=pipeline, path=<path_of_new_dap>)

Clear flash

Since pipeline will start when powering the device, this can lead to unnecessary heating. If you would like to clear the flashed pipeline, use the code snippet below.
Python
1import depthai as dai
2(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
3if not f:
4    print('No devices found, exiting...')
5    exit(-1)
6
7with dai.DeviceBootloader(bl) as bootloader:
8    bootloader.flashClear()
9    print('Successfully cleared bootloader flash')

Factory reset

In case you have soft-bricked your device, or just want to clear everything (flashed pipeline/assets and bootloader config), we recommend using the Device Manager. Factory reset will also flash the latest bootloader.