Skip to content

Commit a6a24d6

Browse files
authored
Merge pull request #995 from luxonis/standalone_docs
Updated standalone mode docs to make it clearer
2 parents c5c64a1 + 0754857 commit a6a24d6

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

docs/source/tutorials/standalone_mode.rst

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Standalone mode
22
===============
33

4-
**Standalone / Hostless / On-The-Edge mode** means that the camera starts the (:ref:`flashed <Flash the pipeline>`) application as soon as it gets power, without being connected to any particular host computer.
4+
**Standalone** mode means that the camera starts the (:ref:`flashed <Flash the pipeline>`) application as soon as it gets power, without being connected to any particular host computer.
55
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.)
66

77
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.
@@ -15,7 +15,7 @@ Standalone mode is **only possible on OAKs that have on-board flash** memory, wh
1515
- License Plate Recognition (LPR) camera (`demo here <https://github.com/luxonis/depthai-experiments/tree/master/gen2-license-plate-recognition>`__). Each camera does vehicle detection, license plate detection and LPR, and only reports license plate (in string) to a server.
1616
- Fall detection for elderly people (`demo here <https://www.youtube.com/watch?v=npiG-Dy7yQ4>`__). 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.
1717

18-
In case you already have a computer on-board (eg. a robot/drone), standalone mode isn't as useful, and just adds extra complexity.
18+
In case you already have a computer on-board (eg. a robot/drone), standalone mode isn't as useful, and adds extra complexity.
1919

2020
Communication with the camera
2121
#############################
@@ -35,35 +35,43 @@ Converting a demo to standalone mode
3535
####################################
3636

3737
Since there won't be any communication between the host and the device, you first need to remove all
38-
:ref:`XLinkOut` and :ref:`XLinkIn` nodes. This means that the device will only communicate with the "outside world"
38+
:ref:`XLinkOut` and :ref:`XLinkIn` nodes.
39+
40+
This means that the device will only communicate with the "outside world"
3941
via either SPI (:ref:`SPIOut`/:ref:`SPIIn`) or :ref:`Script` node (GPIO/UART or network protocols if you have
4042
OAK POE mode; HTTP/TCP/UDP...).
4143

42-
Next thing you can also remove the host-side code, which usually looks something like this:
44+
**Example**: Let's update `PoE TCP Streaming <https://github.com/luxonis/depthai-experiments/tree/master/gen2-poe-tcp-streaming>`__ ``oak.py`` script to standalone mode.
45+
We'll remove the ``dai.Device(pipeline)`` part, and replace it with :ref:`Flash the pipeline`.
4346

44-
.. code-block:: python
4547

46-
with dai.Device(pipeline) as device:
47-
videoQ = device.getOutputQueue("video")
48-
faceDetQ = device.getOutputQueue("face_det")
49-
nnQ = device.getOutputQueue("nn")
48+
.. code-block:: diff
5049
51-
while True:
52-
frame = videoQ.get().getCvFrame()
53-
# ...
50+
conn.send(bytes(header, encoding='ascii'))
51+
conn.send(data)
52+
except Exception as e:
53+
node.warn("Client disconnected")
54+
""")
55+
- # Connect to the device (via host computer)
56+
- with dai.Device(pipeline) as device:
57+
- print("Connected")
58+
- while True:
59+
- time.sleep(1)
60+
+ # Flash the app to the device
61+
+ (f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
62+
+ bootloader = dai.DeviceBootloader(bl)
63+
+ progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
64+
+ bootloader.flash(progress, pipeline)
5465
5566
56-
After you remove all host-side code, you would only be left with the :ref:`Pipeline` definition (with nodes/links).
57-
Since device no longer communicates with the host, you need to "route" your program's output through either SPI
58-
or script node, as mentioned above.
67+
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 <https://github.com/luxonis/depthai-experiments/blob/master/gen2-poe-tcp-streaming/host.py>`__)
68+
and start receiving the video stream.
5969

6070
Flash the bootloader
6171
####################
6272

6373
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.
64-
The :ref:`Bootloader` is packaged together with the depthai, so if you have the latest depthai version, you can flash the
65-
latest bootloader version. To flash the latest bootloader, we suggest using the :ref:`Device Manager`. To view the API code behind
66-
it, see :ref:`Flash Bootloader` example code.
74+
To flash the latest bootloader, we suggest using the :ref:`Device Manager`. To view the API code behind it, see :ref:`Flash Bootloader` example code.
6775

6876
Flash the pipeline
6977
##################
@@ -91,6 +99,9 @@ can flash the pipeline to the device, along with its assests (eg. AI models). Yo
9199
After successfully flashing the pipeline, it will get started automatically when you power up the device.
92100
If you would like to change the flashed pipeline, simply re-flash it again.
93101

102+
DepthAI Application Package (.dap)
103+
##################################
104+
94105
Alternatively, you can also flash the pipeline with the :ref:`Device Manager`. For this approach, you will need a Depthai Application Package (.dap), which you
95106
can create with the following script:
96107

0 commit comments

Comments
 (0)