Skip to content

Commit 6610f30

Browse files
committed
Capture image in pytest
1 parent 706aaf6 commit 6610f30

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

.github/workflows/build-run-applications.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ jobs:
196196
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi/"
197197
run: |
198198
pip install --prefer-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pytest-custom_exit_code opencv-python numpy
199-
apt-get update && apt-get install -y libgl1
200199
- name: Download latest results
201200
uses: actions/download-artifact@v4
202201
with:
@@ -205,7 +204,6 @@ jobs:
205204
- name: Run apps
206205
run: |
207206
pytest --suppress-no-test-exit-code --ignore-glob '*/managed_components/*' --ignore=.github --junit-xml=${{ env.TEST_RESULT_FILE }} --target=${{ matrix.runner.target }} -m ${{ matrix.runner.marker }} --build-dir=build_${{ matrix.runner.runs-on }} ${{ env.PYTEST_BENCHMARK_IGNORE }}
208-
python .github/ci/runner_camera.py
209207
- name: Upload test results
210208
uses: actions/upload-artifact@v4
211209
if: always()

examples/display/pytest_display.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
1+
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: CC0-1.0
33

44
import pytest
55
from pytest_embedded import Dut
6+
from pytest_helpers import bsp_test_image
67

78

89
@pytest.mark.esp_box_3
@@ -20,6 +21,8 @@
2021
@pytest.mark.m5stack_core_s3
2122
@pytest.mark.m5stack_core_s3_se
2223
@pytest.mark.m5_atom_s3
23-
def test_display_example(dut: Dut) -> None:
24+
def test_display_example(dut: Dut, request) -> None:
25+
board = request.node.callspec.id
2426
dut.expect_exact('example: Display LVGL animation')
2527
dut.expect_exact('main_task: Returned from app_main()')
28+
bsp_test_image(board, "")

examples/pytest_helpers.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-License-Identifier: Apache-2.0
3+
import cv2
4+
5+
6+
def bsp_capture_image(image_path):
7+
# Return video from the first webcam on your computer.
8+
cap = cv2.VideoCapture(0)
9+
# reads frames from a camera
10+
# ret checks return at each frame
11+
ret, frame = cap.read()
12+
if ret:
13+
# TODO: Change size image
14+
# TODO: Crop image
15+
16+
# Save image
17+
cv2.imwrite(image_path, frame)
18+
print(f"Image saved {image_path}")
19+
else:
20+
print("Cannot save image.")
21+
22+
# Close the window / Release webcam
23+
cap.release()
24+
25+
26+
def bsp_test_image(board, expectation):
27+
image_file = f"snapshot_{board}.jpg"
28+
bsp_capture_image(image_file)

0 commit comments

Comments
 (0)