Skip to content

Conversation

@hakehuang
Copy link
Contributor

  1. for test machine without GUI, we need support open-cv-headless mode.
  2. Enable mimxrt1170_evk@A
  3. parse environment variable, which is missed in former PR.

@hakehuang
Copy link
Contributor Author

test log

DEBUG   - run status: mimxrt1170_evk@A/mimxrt1176/cm7/zephyr/tests.drivers.display.check.shield passed
INFO    - 1/1 mimxrt1170_evk@A/mimxrt1176/cm7 tests.drivers.display.check.shield           PASSED (device: JTAQCQAR, 72.943s <zephyr>)
INFO    -                                    tests.drivers.display.check.shield.test_display_harness                     PASSED

INFO    - 4 test scenarios (4 configurations) selected, 3 configurations filtered (3 by static filter, 0 at runtime).
Summary
├── Total test suites: 4
├── Processed test suites: 4
│   ├── Filtered test suites: 3
│   │   ├── Filtered test suites (static): 3
│   │   └── Filtered test suites (at runtime): 0
│   └── Selected test suites: 1
│       ├── Skipped test suites: 0
│       ├── Passed test suites: 1
│       ├── Built only test suites: 0
│       ├── Failed test suites: 0
│       └── Errors in test suites: 0
└── Total test cases: 4
    ├── Filtered test cases: 3
    └── Selected test cases: 1
        ├── Passed test cases: 1
        ├── Skipped test cases: 0
        ├── Built only test cases: 0
        ├── Blocked test cases: 0
        ├── Failed test cases: 0
        └── Errors in test cases: 0
INFO    - 1 of 1 executed test configurations passed (100.00%), 0 built (not run), 0 failed, 0 errored, with no warnings in 102.90 seconds.
INFO    - 1 of 1 executed test cases passed (100.00%) on 1 out of total 1152 platforms (0.09%).
INFO    - 1 test configurations executed on platforms, 0 test configurations were only built.

@hakehuang
Copy link
Contributor Author

hakehuang commented Aug 29, 2025

@JarmouniA @danieldegrasse @jfischer-no @nashif Please help to review, this enhance the test for headless(No Graphic) condition, also fix a missing in test path parser. Thanks

@JarmouniA
Copy link
Contributor

Cc @Finomnis

@Finomnis
Copy link
Contributor

Cc @Finomnis

Not sure if I can help, didn't work with this part of Zephyr yet

@JarmouniA
Copy link
Contributor

JarmouniA commented Aug 29, 2025

Cc @Finomnis

Not sure if I can help, didn't work with this part of Zephyr yet

Sorry, I thought the PR was about headless SDL for some unknown reason, hence the ping :)

@jfischer-no
Copy link
Contributor

@JarmouniA @danieldegrasse @jfischer-no @nashif Please help to review, this enhance the test for headless(No Graphic) condition, also fix a missing in test path parser. Thanks

 tests: display: support headless mode

1. support headless mode
2. add parser for environment path

@hakehuang I think the commit message could be improved. I suggest writing about the motivation and why, rather than listing what has actually changed in bullet form.

@hakehuang hakehuang force-pushed the display_support_opencv_headless branch from 68c8642 to ae888ba Compare September 1, 2025 13:07
@hakehuang
Copy link
Contributor Author

hakehuang commented Sep 1, 2025

@hakehuang I think the commit message could be improved. I suggest writing about the motivation and why, rather than listing what has actually changed in bullet form.

@jfischer-no I update the commit message, but not sure is it clear enough.

for test machine without display, need support open-cv-headless mode.

@hakehuang hakehuang force-pushed the display_support_opencv_headless branch 2 times, most recently from 9f5d197 to 804953a Compare September 2, 2025 08:14
@hakehuang
Copy link
Contributor Author

@JarmouniA @danieldegrasse @jfischer-no @nashif Please help to review

for test machine without display, need support open-cv-headless mode.

1. support headless mode
2. add parser for environment path

Signed-off-by: Hake Huang <[email protected]>
enable mimxrt1170_evk@A
add timeout, as for big screen, the fist step takes a long time

Signed-off-by: Hake Huang <[email protected]>
@hakehuang hakehuang force-pushed the display_support_opencv_headless branch from a00ea65 to a5409fa Compare September 5, 2025 08:08
JarmouniA
JarmouniA previously approved these changes Sep 5, 2025
@hakehuang
Copy link
Contributor Author

@josuah please help to take a look, thanks.

@josuah
Copy link
Contributor

josuah commented Sep 10, 2025

Hello! I tried again in a debootstrap environment where display is not available ($DISPLAY is empty) and it seems like the Qt libraries did complain.

This is a known issue when trying to load the Qt libraries when X11 does not work.

(zephyrproject) ~/zephyrproject/zephyr/scripts/pylib/display-twister-harness HEAD $ python -m camera_shield.main --config config.yaml
Authorization required, but no authorization protocol specified

qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/panoramix/zephyrproject/.venv/lib/python3.13/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

Aborted
(zephyrproject) ~/zephyrproject/zephyr/scripts/pylib/display-twister-harness HEAD $ echo "$DISPLAY"

(zephyrproject) ~/zephyrproject/zephyr/scripts/pylib/display-twister-harness HEAD $ 

However, with this small patch, it did not have any issue:

diff --git a/scripts/pylib/display-twister-harness/camera_shield/main.py b/scripts/pylib/display-twister-harness/camera_shield/main.py
index b0afd6ec2c6..6bf96ccb4a8 100644
--- a/scripts/pylib/display-twister-harness/camera_shield/main.py
+++ b/scripts/pylib/display-twister-harness/camera_shield/main.py
@@ -94,8 +94,9 @@ class Application:
 
                 # Maintain OpenCV event loop
                 try:
-                    if cv2.waitKey(1) == 27:  # ESC key
-                        break
+                    break
+                    #if cv2.waitKey(1) == 27:  # ESC key
+                    #    break
                 except Exception as e:
                     error_msg = str(e).lower()
                     if any(

And I could get these results:

(zephyrproject) ~/zephyrproject/zephyr/scripts/pylib/display-twister-harness HEAD $ python -m camera_shield.main --config config.yaml
Camera 0 Settings:
Resolution: 1280                x720
  FPS: 10.00
  Auto Focus: ON
  Auto White Balance: ON
initialize
compare
/home/panoramix/zephyrproject/zephyr/scripts/pylib/display-twister-harness/./fingerprints not exist
VideoSignaturePlugin result: no match

The problem is that Qt calls abort(), which is always a problem as we cannot recover from this error as the Qt library exits before returning to Python.

@hakehuang
Copy link
Contributor Author

The problem is that Qt calls abort(), which is always a problem as we cannot recover from this error as the Qt library exits before returning to Python.

@josuah, skip calling the GUI related function can avoid such issue, but the recommend way is to replace is to do below

if you server does not have display please do below

pip uninstall opencv-python
pip install opencv-python-headless
export QT_QPA_PLATFORM=offscreen

@hakehuang
Copy link
Contributor Author

The problem is that Qt calls abort(), which is always a problem as we cannot recover from this error as the Qt library exits before returning to Python.

@josuah, skip calling the GUI related function can avoid such issue, but the recommend way is to replace is to do below

if you server does not have display please do below

pip uninstall opencv-python
pip install opencv-python-headless
export QT_QPA_PLATFORM=offscreen

@josuah
Copy link
Contributor

josuah commented Sep 10, 2025

How about adding a flag to control whether a GUI is present or not?

For instance:

  • if --headless is selected, then show_frame() calls cv2.imwrite() instead of cv2.imshow(), and prints frame captured at ./path_to_file.png and calls input() instead of cv2.waitKey().
  • if --headless is absent, this runs the same script as now.

Or do you prefer to always to auto-detection of the GUI?
If so the current PR improves the support for headless mode, no problem.

Thank you for the improvement!

josuah
josuah previously approved these changes Sep 10, 2025
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I must have missed the pip install opencv-python-headless line. Sorry about that. It all works on first try now!

@JarmouniA
Copy link
Contributor

pip install opencv-python-headless

Should be added in the doc.

@hakehuang
Copy link
Contributor Author

hakehuang commented Sep 11, 2025

pip install opencv-python-headless

Should be added in the doc.

sure, update the document 109cc06 @JarmouniA , @josuah

@hakehuang hakehuang dismissed stale reviews from josuah and JarmouniA via 109cc06 September 11, 2025 03:10
@josuah
Copy link
Contributor

josuah commented Sep 11, 2025

The documentation is not being built, so CI does not trigger any warning.

You may see that it is mixing Markdown and RST syntax, and I guess us all developers are too used to Markdown to realize it is invalid syntax in RST:

https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/pylib/display-twister-harness/camera_shield/README.rst

Maybe it can be improved in a different PR as this is not related to documentation.

Thanks!

@hakehuang hakehuang force-pushed the display_support_opencv_headless branch 2 times, most recently from 22488fe to 86b5956 Compare September 11, 2025 12:11
@hakehuang
Copy link
Contributor Author

Maybe it can be improved in a different PR as this is not related to documentation.

Thanks!

@JarmouniA. I update the document and check with rstcheck now the format should be right. Thanks to point this out.

add Installation Guide section

Signed-off-by: Hake Huang <[email protected]>
@hakehuang hakehuang force-pushed the display_support_opencv_headless branch from 86b5956 to bb22e13 Compare September 12, 2025 03:00
@sonarqubecloud
Copy link

@hakehuang hakehuang requested a review from JarmouniA September 12, 2025 05:00
@cfriedt cfriedt merged commit 504fb01 into zephyrproject-rtos:main Sep 13, 2025
47 checks passed
Comment on lines +114 to +118
- clone code

::

git clone https://github.com/hakehuang/camera_shield
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks wrong? also, this sould be included in the Zephyr documentation proper, not as a separate README that is virtually invisible to anyone browsing the online docs. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kartben , I move the whole https://github.com/hakehuang/camera_shield into the zephyr already, should I remove this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kartben , I move the whole hakehuang/camera_shield into the zephyr already, should I remove this file?

not remove it, we want proper docs for this :)
see #98398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants