eiq-examples: improvements

* do not run the demos in background, if not they can not be ctrl+c.
* fix service dependencies: required camera and weston.
* patch the examples to:
** set camera resolution to 1280x720
** set default format to ov5640 camera (YUYV)
** detect the "x" event when the demo application is running in windowed mode (not fullscreen).

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2024-10-02 12:20:10 +02:00
parent adb6a37e61
commit 82851b0308
4 changed files with 146 additions and 5 deletions

View File

@ -13,6 +13,7 @@ SRC_URI += " \
file://patches/0001-Customize-EiQ-demos.patch \ file://patches/0001-Customize-EiQ-demos.patch \
file://patches/0002-dms-update-the-demo-to-use-the-landmark-full-model.patch \ file://patches/0002-dms-update-the-demo-to-use-the-landmark-full-model.patch \
file://patches/0003-download_models-update-the-download-location-of-some.patch \ file://patches/0003-download_models-update-the-download-location-of-some.patch \
file://patches/0004-improvements-capture-x-windows-and-increase-resoluti.patch \
file://scripts/launch_eiq_demo.sh \ file://scripts/launch_eiq_demo.sh \
file://service/eiqdemo.service \ file://service/eiqdemo.service \
" "
@ -25,7 +26,7 @@ do_download_transform_models() {
do_download_transform_models[network] = "1" do_download_transform_models[network] = "1"
# Add the custom task to download and transform the models. # Add the custom task to download and transform the models.
addtask do_download_transform_models after do_patch before do_install addtask download_transform_models after do_patch before do_install
inherit systemd inherit systemd

View File

@ -0,0 +1,138 @@
From: Isaac Hermida <isaac.hermida@digi.com>
Date: Wed, 2 Oct 2024 11:58:15 +0200
Subject: [PATCH] improvements: capture "x" windows and increase resolution
When running in window mode (no fullscreen), stop the application.
Increase the camera resolution to 1280x720.
Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
---
dms/main.py | 13 +++++++++----
face_recognition/main.py | 12 ++++++++----
gesture_detection/main.py | 13 +++++++++----
object_detection/main.py | 13 +++++++++----
4 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/dms/main.py b/dms/main.py
index e74b6be1b938..99b501ca2194 100644
--- a/dms/main.py
+++ b/dms/main.py
@@ -14,10 +14,10 @@ from eye_landmark import EyeMesher
from face_landmark import FaceMesher
from utils import *
-WIDTH=640
-HEIGH=480
-FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
-FORMAT=0 # None, skip (YUYV, default), 0 MJPG (for usb camera)
+WIDTH=1280
+HEIGH=720
+FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
+FORMAT=None # None, skip (YUYV, default), 0 MJPG (for usb camera)
# Always enforce the Ethos NPU, use the converted vela models
MODEL_PATH = pathlib.Path("../vela_models/")
@@ -197,6 +197,11 @@ while ret:
if FLIP is not None:
image = cv2.flip(image, FLIP)
if cv2.waitKey(1) & 0xFF == ord('q'):
+ # "q" key pressed
+ break
+
+ if cv2.getWindowProperty(window_name, cv2.WND_PROP_AUTOSIZE):
+ # Window closed by click 'X'
break
except Exception as err:
# Ignore exceptions
diff --git a/face_recognition/main.py b/face_recognition/main.py
index 33ffa7161fac..40ca9f8afb91 100644
--- a/face_recognition/main.py
+++ b/face_recognition/main.py
@@ -13,10 +13,10 @@ from face_detection import YoloFace
from face_recognition import Facenet
from face_database import FaceDatabase
-WIDTH=640
-HEIGH=480
-FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
-FORMAT=0 # None, skip (YUYV, default), 0 MJPG (for usb camera)
+WIDTH=1280
+HEIGH=720
+FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
+FORMAT=None # None, skip (YUYV, default), 0 MJPG (for usb camera)
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -144,6 +144,10 @@ while True:
while cv2.waitKey(100) & 0xFF == 0xFF:
pass
+ if cv2.getWindowProperty(window_name, cv2.WND_PROP_AUTOSIZE):
+ # Window closed by click 'X'
+ break
+
time.sleep(2)
vid.release()
cv2.destroyAllWindows()
diff --git a/gesture_detection/main.py b/gesture_detection/main.py
index 15b85976fd72..8ad2c9bd409b 100644
--- a/gesture_detection/main.py
+++ b/gesture_detection/main.py
@@ -63,10 +63,10 @@ if args.input.isdigit():
else:
cap_input = args.input
-WIDTH=640
-HEIGH=480
-FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
-FORMAT=0 # None, skip (YUYV, default), 0 MJPG (for usb camera)
+WIDTH=1280
+HEIGH=720
+FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
+FORMAT=None # None, skip (YUYV, default), 0 MJPG (for usb camera)
# This pipeline for the OV5640 camera in case the other command fails
# capture = cv2.VideoCapture("v4l2src device=%s ! imxvideoconvert_pxp ! video/x-raw,format=RGB16,width=%d,height=%d " \
@@ -100,6 +100,11 @@ while ret:
ret, frame = capture.read()
if cv2.waitKey(1) & 0xFF == ord('q'):
+ # "q" key pressed
+ break
+
+ if cv2.getWindowProperty(window_name, cv2.WND_PROP_AUTOSIZE):
+ # Window closed by click 'X'
break
cv2.waitKey(2000)
diff --git a/object_detection/main.py b/object_detection/main.py
index efa614ebd44b..34ba17eddffb 100644
--- a/object_detection/main.py
+++ b/object_detection/main.py
@@ -13,10 +13,10 @@ import argparse
from labels import label2string
-WIDTH=640
-HEIGH=480
-FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
-FORMAT=0 # None, skip (YUYV, default), 0 MJPG (for usb camera)
+WIDTH=1280
+HEIGH=720
+FLIP=None # None, skip, 0: Flip vertically, 1: Flip horizontally (around the y-axis), -1: Flip both vertically and horizontally
+FORMAT=None # None, skip (YUYV, default), 0 MJPG (for usb camera)
# Always enforce the Ethos NPU, use the converted vela models
MODEL_PATH = "../vela_models/ssd_mobilenet_v1_quant_vela.tflite"
@@ -122,6 +122,11 @@ while ret:
if FLIP is not None:
frame = cv2.flip(frame, FLIP)
if cv2.waitKey(1) & 0xFF == ord('q'):
+ # "q" key pressed
+ break
+
+ if cv2.getWindowProperty(window_name, cv2.WND_PROP_AUTOSIZE):
+ # Window closed by click 'X'
break
cv2.waitKey(2000)

View File

@ -36,4 +36,4 @@ DEMO_DIR="/usr/bin/eiq-examples-git/${DEMO}"
cd "${DEMO_DIR}" || exit cd "${DEMO_DIR}" || exit
# Execute the demo pre-configuring the display settings. # Execute the demo pre-configuring the display settings.
WAYLAND_DISPLAY=/run/wayland-0 DISPLAY=:0.0 XDG_RUNTIME_DIR=/run/user/0 python3 main.py -i /dev/video0 -f -d /usr/lib/libethosu_delegate.so & WAYLAND_DISPLAY=/run/wayland-0 DISPLAY=:0.0 XDG_RUNTIME_DIR=/run/user/0 python3 main.py -i /dev/video0 -f -d /usr/lib/libethosu_delegate.so

View File

@ -1,10 +1,12 @@
[Unit] [Unit]
Description=Initialization of EiQ DMS demo Description=Initialization of EiQ DMS demo
After=multi-user.target After=graphical.target
ConditionPathExists=/dev/video0
[Service] [Service]
Type=forking Type=exec
RemainAfterExit=yes
ExecStart=/etc/demos/scripts/launch_eiq_demo.sh ExecStart=/etc/demos/scripts/launch_eiq_demo.sh
[Install] [Install]
WantedBy=multi-user.target WantedBy=graphical.target