跳到主要內容
支援知識庫

在Raspbian*作系統上使用系統服務啟動OpenVINO™工具包 Python 應用程式

內容類型: 安裝與設定   |   文章 ID: 000055416   |   最近查看日期: 2023 年 11 月 20 日

介紹

本指南為使用者提供了創建系統服務的步驟,以初始化OpenVINO™工具包環境變數並運行適用於Raspbian* 的 benchmark_app.py Python 應用程式。此程式可能適用於其他 Linux* 發行版,但本指南適用於 Raspbian*作系統。

以下步驟假定您已安裝OpenVINO™工具包,並且您的安裝已經過驗證。如果您尚未這樣做,請存取以下連結:

系統要求

  • Raspian* Buster,32 位

創建系統服務檔的步驟

  1. 安裝工具並下載必要的檔案:

    sudo pip install progress
    cd ~/

    wget https://storage.openvinotoolkit.org/repositories/open_model_zoo/2022.1/models_bin/3/person-vehicle-bike-detection-crossroad-0078/FP16/person-vehicle-bike-detection-crossroad-0078.bin -O ~/下載/person-vehicle-bike-detection-crossroad-0078.bin
    wget https://storage.openvinotoolkit.org/repositories/open_model_zoo/2022.1/models_bin/3/person-vehicle-bike-detection-crossroad-0078/FP16/person-vehicle-bike-detection-crossroad-0078.xml -O ~/下載/person-vehicle-bike-detection-crossroad-0078.xml
    wget https://github.com/intel-iot-devkit/sample-videos/raw/master/people-detection.mp4 -O ~/Downloads/people-detection.mp4

  2. 建立 bash 指令稿以初始化 OpenVINO* 環境變數並執行 python 腳稿:

    vi ~/openvino-object-detection-demo-script

    #!/bin/bash
    來源 /home/pi/openvino_dist/setupvars.sh
    /usr/bin/python3 /home/pi/openvino_dist/extras/open_model_zoo/demos/object_detection_demo/python/object_detection_demo.py -i /home/pi/Downloads/people-detection.mp4 -m /home/pi/Downloads/person-vehicle-bike-detection-crossroad-0078.xml -d MYRIAD -at ssd

  3. 變更 bash 文稿檔權限與所有權:

    chmod u+x ~/openvino-object-detection-demo-script

  4. /etc/systemd/system 下建立服務文件,內容如下所示:

    sudo vi /etc/systemd/system/openvino-object-detection-demo.service

    [Unit]
    Description=Init OpenVINO env and run python object detection demo
    After=network.target

    [Service]
    ExecStart=/home/pi/openvino-object-detection-demo-script
    WorkingDirectory=/home/pi
    StandardOutput=inherit
    StandardError=inherit
    Restart=on-failure
    User=pi

    [Install]
    WantedBy=multi-user.target

  5. 啟用系統服務以在開機時啟動並啟動系統服務:

    sudo systemctl enable openvino-object-detection-demo.service
    sudo systemctl start openvino-object-detection-demo.service

  6. 要檢查系統服務狀態:

    sudo systemctl status openvino-object-detection-demo.service

  7. 或者要在開機期間停用服務,請先停止服務,然後再停用服務:

    sudo systemctl stop openvino-object-detection-demo.service
    sudo systemctl disable openvino-object-detection-demo.service

如需更多有關 Linux* 系統服務的資訊,請查看 systemd 的手冊頁。

man systemd

相關產品

本文章適用 2 產品。

免責聲明

這個頁面的內容綜合了英文原始內容的人工翻譯譯文與機器翻譯譯文。本內容是基於一般資訊目的,方便您參考而提供,不應視同完整或準確的內容。如果這個頁面的英文版與譯文之間發生任何牴觸,將受英文版規範及管轄。 查看這個頁面的英文版。