From 5028f7d21c06da3556203afb3837e88d3b8e5022 Mon Sep 17 00:00:00 2001 From: rise0chen Date: Fri, 6 Dec 2024 14:03:55 +0800 Subject: [PATCH] perf: default camera index --- .github/workflows/publish.yml | 10 +++++++++- camera/bin/src/camera.py | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 427819c..e256a89 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,8 +10,16 @@ jobs: runs-on: ubuntu-latest container: registry.cn-shanghai.aliyuncs.com/lebai/util:14.04 steps: + - name: Run on old node + run: | + apt update && apt -y install wget + touch "$HOME/.bashrc" + wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + nvm install 14.21.3 - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Install Tools diff --git a/camera/bin/src/camera.py b/camera/bin/src/camera.py index 03dd6a6..098464b 100644 --- a/camera/bin/src/camera.py +++ b/camera/bin/src/camera.py @@ -46,6 +46,7 @@ def search_camera(): camera_list.append(i) cap.release() lebai.set_item("plugin_camera_indexs", json.dumps(camera_list)) + return camera_list def init_camera(): index = (lebai.get_item("plugin_camera_index"))['value'] @@ -67,7 +68,9 @@ def init_camera(): def main(): cap = init_camera() if not cap.isOpened(): - search_camera() + cameras = search_camera() + if len(cameras) == 1: + lebai.set_item("plugin_camera_index", str(cameras[0])) exit(1) images_dir = os.path.join(current_dir, "../../images")