DepthAI v2 has been superseded by DepthAI v3. You are viewing legacy documentation.
此页面由 AI 自动翻译。查看英文原版
DepthAI 教程
DepthAI API 参考

本页目录

  • 演示
  • 设置
  • 源代码
  • 管道

系统信息

此示例演示了如何从开发板获取系统信息(内存使用率、CPU 使用率和温度)。

演示

示例脚本输出
Command Line
1Ddr used / total - 0.13 / 414.80 MiB
2  Cmx used / total - 2.24 / 2.50 MiB
3  LeonCss heap used / total - 4.17 / 46.41 MiB
4  LeonMss heap used / total - 2.87 / 27.58 MiB
5  Chip temperature - average: 38.59, css: 39.81, mss: 37.71, upa: 38.65, dss: 38.18
6  Cpu usage - Leon CSS: 7.08%, Leon MSS: 1.48 %
7  ----------------------------------------
8  Ddr used / total - 0.13 / 414.80 MiB
9  Cmx used / total - 2.24 / 2.50 MiB
10  LeonCss heap used / total - 4.17 / 46.41 MiB
11  LeonMss heap used / total - 2.87 / 27.58 MiB
12  Chip temperature - average: 38.59, css: 39.58, mss: 37.94, upa: 38.18, dss: 38.65
13  Cpu usage - Leon CSS: 1.55%, Leon MSS: 0.30 %
14  ----------------------------------------
15  Ddr used / total - 0.13 / 414.80 MiB
16  Cmx used / total - 2.24 / 2.50 MiB
17  LeonCss heap used / total - 4.17 / 46.41 MiB
18  LeonMss heap used / total - 2.87 / 27.58 MiB
19  Chip temperature - average: 38.94, css: 40.04, mss: 38.18, upa: 39.35, dss: 38.18
20  Cpu usage - Leon CSS: 0.56%, Leon MSS: 0.06 %
21  ----------------------------------------
22  Ddr used / total - 0.13 / 414.80 MiB
23  Cmx used / total - 2.24 / 2.50 MiB
24  LeonCss heap used / total - 4.17 / 46.41 MiB
25  LeonMss heap used / total - 2.87 / 27.58 MiB
26  Chip temperature - average: 39.46, css: 40.28, mss: 38.88, upa: 39.81, dss: 38.88
27  Cpu usage - Leon CSS: 0.51%, Leon MSS: 0.06 %
28  ----------------------------------------
  • upa 代表 SHAVE 块的温度
  • dss 代表 DDR 子系统的温度

设置

请运行 安装脚本 以下载所有必需的依赖项。请注意,此脚本必须在 git 上下文中运行,因此您必须先下载 depthai-python 存储库,然后运行脚本
Command Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.py
有关更多信息,请遵循 安装指南

源代码

Python

Python
GitHub
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5
6def printSystemInformation(info):
7    m = 1024 * 1024 # MiB
8    print(f"Ddr used / total - {info.ddrMemoryUsage.used / m:.2f} / {info.ddrMemoryUsage.total / m:.2f} MiB")
9    print(f"Cmx used / total - {info.cmxMemoryUsage.used / m:.2f} / {info.cmxMemoryUsage.total / m:.2f} MiB")
10    print(f"LeonCss heap used / total - {info.leonCssMemoryUsage.used / m:.2f} / {info.leonCssMemoryUsage.total / m:.2f} MiB")
11    print(f"LeonMss heap used / total - {info.leonMssMemoryUsage.used / m:.2f} / {info.leonMssMemoryUsage.total / m:.2f} MiB")
12    t = info.chipTemperature
13    print(f"Chip temperature - average: {t.average:.2f}, css: {t.css:.2f}, mss: {t.mss:.2f}, upa: {t.upa:.2f}, dss: {t.dss:.2f}")
14    print(f"Cpu usage - Leon CSS: {info.leonCssCpuUsage.average * 100:.2f}%, Leon MSS: {info.leonMssCpuUsage.average * 100:.2f} %")
15    print("----------------------------------------")
16
17# Create pipeline
18pipeline = dai.Pipeline()
19
20# Define source and output
21sysLog = pipeline.create(dai.node.SystemLogger)
22linkOut = pipeline.create(dai.node.XLinkOut)
23
24linkOut.setStreamName("sysinfo")
25
26# Properties
27sysLog.setRate(1)  # 1 Hz
28
29# Linking
30sysLog.out.link(linkOut.input)
31
32# Connect to device and start pipeline
33with dai.Device(pipeline) as device:
34
35    # Output queue will be used to get the system info
36    qSysInfo = device.getOutputQueue(name="sysinfo", maxSize=4, blocking=False)
37
38    while True:
39        sysInfo = qSysInfo.get()  # Blocking call, will wait until a new data has arrived
40        printSystemInformation(sysInfo)

C++

1#include <iostream>
2
3// Includes common necessary includes for development using depthai library
4#include "depthai/depthai.hpp"
5void printSystemInformation(dai::SystemInformation info) {
6    printf("Ddr used / total - %.2f / %.2f MiB\n", info.ddrMemoryUsage.used / (1024.0f * 1024.0f), info.ddrMemoryUsage.total / (1024.0f * 1024.0f));
7    printf("Cmx used / total - %.2f / %.2f MiB\n", info.cmxMemoryUsage.used / (1024.0f * 1024.0f), info.cmxMemoryUsage.total / (1024.0f * 1024.0f));
8    printf("LeonCss heap used / total - %.2f / %.2f MiB\n",
9           info.leonCssMemoryUsage.used / (1024.0f * 1024.0f),
10           info.leonCssMemoryUsage.total / (1024.0f * 1024.0f));
11    printf("LeonMss heap used / total - %.2f / %.2f MiB\n",
12           info.leonMssMemoryUsage.used / (1024.0f * 1024.0f),
13           info.leonMssMemoryUsage.total / (1024.0f * 1024.0f));
14    const auto& t = info.chipTemperature;
15    printf("Chip temperature - average: %.2f, css: %.2f, mss: %.2f, upa: %.2f, dss: %.2f\n", t.average, t.css, t.mss, t.upa, t.dss);
16    printf("Cpu usage - Leon CSS: %.2f %%, Leon MSS: %.2f %%\n", info.leonCssCpuUsage.average * 100, info.leonMssCpuUsage.average * 100);
17    printf("----------------------------------------\n");
18}
19
20int main() {
21    // Create pipeline
22    dai::Pipeline pipeline;
23
24    // Define source and output
25    auto sysLog = pipeline.create<dai::node::SystemLogger>();
26    auto xout = pipeline.create<dai::node::XLinkOut>();
27
28    xout->setStreamName("sysinfo");
29
30    // Properties
31    sysLog->setRate(1.0f);  // 1 hz updates
32
33    // Linking
34    sysLog->out.link(xout->input);
35
36    // Connect to device and start pipeline
37    dai::Device device(pipeline);
38
39    // Output queue will be used to get the system info
40    auto qSysInfo = device.getOutputQueue("sysinfo", 4, false);
41
42    while(true) {
43        auto sysInfo = qSysInfo->get<dai::SystemInformation>();
44        printSystemInformation(*sysInfo);
45    }
46    return 0;
47}

管道

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。