25 - System information

This example shows how to get system information (memory usage, cpu usage and temperature) from the board.

Demo

Example script output

Drr used / total - 0.13 / 414.80 MiB
Cmx used / total - 2.24 / 2.50 MiB
LeonCss heap used / total - 4.17 / 46.41 MiB
LeonMss heap used / total - 2.87 / 27.58 MiB
Chip temperature - average: 38.59, css: 39.81, mss: 37.71, upa0: 38.65, upa1: 38.18
Cpu usage - Leon OS: 7.08%, Leon RT: 1.48 %
----------------------------------------
Drr used / total - 0.13 / 414.80 MiB
Cmx used / total - 2.24 / 2.50 MiB
LeonCss heap used / total - 4.17 / 46.41 MiB
LeonMss heap used / total - 2.87 / 27.58 MiB
Chip temperature - average: 38.59, css: 39.58, mss: 37.94, upa0: 38.18, upa1: 38.65
Cpu usage - Leon OS: 1.55%, Leon RT: 0.30 %
----------------------------------------
Drr used / total - 0.13 / 414.80 MiB
Cmx used / total - 2.24 / 2.50 MiB
LeonCss heap used / total - 4.17 / 46.41 MiB
LeonMss heap used / total - 2.87 / 27.58 MiB
Chip temperature - average: 38.94, css: 40.04, mss: 38.18, upa0: 39.35, upa1: 38.18
Cpu usage - Leon OS: 0.56%, Leon RT: 0.06 %
----------------------------------------
Drr used / total - 0.13 / 414.80 MiB
Cmx used / total - 2.24 / 2.50 MiB
LeonCss heap used / total - 4.17 / 46.41 MiB
LeonMss heap used / total - 2.87 / 27.58 MiB
Chip temperature - average: 39.46, css: 40.28, mss: 38.88, upa0: 39.81, upa1: 38.88
Cpu usage - Leon OS: 0.51%, Leon RT: 0.06 %
----------------------------------------

Setup

Please run the following command to install the required dependencies

 python3 -m pip install -U pip
 python3 -m pip install opencv-python
 python3 -m pip install -U --force-reinstall depthai

For additional information, please follow installation guide

Source code

Also available on GitHub

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3

import cv2
import depthai as dai


def print_sys_info(info):
    m = 1024 * 1024 # MiB
    print(f"Drr used / total - {info.ddrMemoryUsage.used / m:.2f} / {info.ddrMemoryUsage.total / m:.2f} MiB")
    print(f"Cmx used / total - {info.cmxMemoryUsage.used / m:.2f} / {info.cmxMemoryUsage.total / m:.2f} MiB")
    print(f"LeonCss heap used / total - {info.leonCssMemoryUsage.used / m:.2f} / {info.leonCssMemoryUsage.total / m:.2f} MiB")
    print(f"LeonMss heap used / total - {info.leonMssMemoryUsage.used / m:.2f} / {info.leonMssMemoryUsage.total / m:.2f} MiB")
    t = info.chipTemperature
    print(f"Chip temperature - average: {t.average:.2f}, css: {t.css:.2f}, mss: {t.mss:.2f}, upa0: {t.upa:.2f}, upa1: {t.dss:.2f}")
    print(f"Cpu usage - Leon OS: {info.leonCssCpuUsage.average * 100:.2f}%, Leon RT: {info.leonMssCpuUsage.average * 100:.2f} %")
    print("----------------------------------------")


# Start defining a pipeline
pipeline = dai.Pipeline()

sys_logger = pipeline.createSystemLogger()
sys_logger.setRate(1)  # 1 Hz

# Create output
linkOut = pipeline.createXLinkOut()
linkOut.setStreamName("sysinfo")
sys_logger.out.link(linkOut.input)

# Connect and start the pipeline
with dai.Device(pipeline) as device:

    # Output queue will be used to get the system info
    q_sysinfo = device.getOutputQueue(name="sysinfo", maxSize=4, blocking=False)

    while True:
        info = q_sysinfo.get()  # Blocking call, will wait until a new data has arrived
        print_sys_info(info)

        if cv2.waitKey(1) == ord('q'):
            break

Got questions?

We’re always happy to help with code or other questions you might have.