A lightweight desktop application for detecting objects in webcam streams and image files using YOLOv8 and PyQt5.
The application is implemented in app/main.py, and uses app/gui.py for the graphical interface and app/detector.py for YOLO inference.
- Real-time webcam object detection
- Image file detection with YOLO annotations
- Camera selection and refresh support
- Bounding boxes and confidence scores displayed on video frames
- Simple PyQt5 GUI for Windows-style desktop use
app/main.py— application entry pointapp/gui.py— PyQt5 user interface and camera handlingapp/detector.py— YOLO model loading and inferenceapp/utils.py— image conversion helper for Qtmodels/— model storage folderscreenshots/— UI example screenshotsrequirements.txt— Python dependencies
- Python 3.8+ recommended
PyQt5opencv-pythonultralytics
- Clone the repository:
git clone <repository-url>
cd edgeai-app-GUI- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txtWith the virtual environment active:
python app/main.py- Click Start Webcam to begin live detection from the selected camera.
- Click Stop Webcam to end the camera feed.
- Click Open Image to choose a static image file and run YOLO detection.
- Click Refresh Cameras if your camera list changes.
- The application loads the YOLO model from
app/yolov8n.pt. - If you do not have a webcam attached, use Open Image to test detection on local images.
setup.shis a helper script that installs the required Python packages.
This project can be packaged as a .deb installer for Ubuntu and configured to run automatically as a systemd service.
- Create the package directory structure:
mkdir -p edgeai-app_1.0/DEBIAN
mkdir -p edgeai-app_1.0/opt/edgeai-app
mkdir -p edgeai-app_1.0/usr/local/bin- Copy the application files into the package layout:
cp -r ./* edgeai-app_1.0/opt/edgeai-app/- Create the launcher script at
edgeai-app_1.0/usr/local/bin/edgeai-app:
cat > edgeai-app_1.0/usr/local/bin/edgeai-app <<'EOF'
#!/bin/bash
source /home/mohammad/virtual_environments/yolo/bin/activate
export QT_QPA_PLATFORM=xcb
python3 /opt/edgeai-app/app/main.py
EOF- Create the package metadata file at
edgeai-app_1.0/DEBIAN/control:
Package: edgeai-app
Version: 1.0
Section: base
Priority: optional
Architecture: amd64
Maintainer: Mohammad
Description: YOLO Object Detection GUI Application
- Set the launcher permissions and build the package:
chmod +x edgeai-app_1.0/usr/local/bin/edgeai-app
chmod -R 755 edgeai-app_1.0
dpkg-deb --build edgeai-app_1.0- Install the package:
sudo dpkg -i edgeai-app_1.0.deb- Run the application:
edgeai-app- Remove the package:
sudo dpkg -r edgeai-app
sudo dpkg --purge edgeai-appNote: Replace
/home/mohammad/virtual_environments/yolo/bin/activatewith your actual virtual environment path if different.
Create the service file at /etc/systemd/system/edgeai-app.service:
[Unit]
Description=YOLO Edge AI GUI Application
After=graphical.target
[Service]
Type=simple
User=mohammad
WorkingDirectory=/opt/edgeai-app/app
Environment=DISPLAY=:0
Environment=QT_QPA_PLATFORM=xcb
Environment=XAUTHORITY=/home/mohammad/.Xauthority
ExecStart=/home/mohammad/virtual_environments/yolo/bin/python3 /opt/edgeai-app/app/main.py
Restart=always
RestartSec=5
[Install]
WantedBy=graphical.targetReload the service definition:
sudo systemctl daemon-reloadEnable auto-start on boot:
sudo systemctl enable edgeai-app.serviceStart the service now:
sudo systemctl start edgeai-app.serviceCheck status:
sudo systemctl status edgeai-app.serviceStop the service:
sudo systemctl stop edgeai-app.serviceDisable auto-start:
sudo systemctl disable edgeai-app.serviceView live service logs:
journalctl -u edgeai-app.service -fAfter=graphical.target- Start after the graphical desktop session is ready.
User=mohammad- Run the service as this user.
ExecStart- Command used to launch the application.
Restart=always- Automatically restart if the app crashes.
WantedBy=graphical.target- Start the service during graphical boot.
- The
.debinstaller places the application under/opt/edgeai-appand the launcher at/usr/local/bin/edgeai-app. - Update all hard-coded paths for your own Ubuntu user and virtual environment locations.
- The desktop service assumes an X11 session; if you use Wayland, adjust display settings accordingly.
Possible causes:
- Missing Qt dependencies
- OpenCV Qt conflicts
- Wayland/X11 configuration issues
Suggested fixes:
sudo apt install libxcb-xinerama0 libxkbcommon-x11-0Use:
export QT_QPA_PLATFORM=xcbVerify available devices:
ls /dev/video*or
v4l2-ctl --list-devicesCheck logs:
journalctl -u edgeai-app.service -fVerify:
- Virtual environment path
- Python interpreter path
- Display environment variables
- User permissions

