A Windows-only demo of a PySide2 GUI that shows a live webcam stream coming from a C++ OpenCV DLL. src/main.py loads src/OpenCV/x64/Release/OpenCV.dll through ctypes, receives each frame through a callback function, and draws it in a Qt window. The full Qt Designer workflow is included, and the Visual Studio project that builds the DLL ships with the SDK.
Important: PySide2 ships wheels for Python 3.7 to 3.10 only. Install one of those Python versions before running 01_venv_create; a newer Python needs the code ported to PySide6.
[Folder Structure]
- CLAUDE.md / AGENT.md: program specification (identical content).
- CHANGELOG.md: change log.
- copyright.txt: copyright notice.
- src/OpenCV/: the Visual Studio C++ project that builds the DLL.
- src/OpenCV/x64/Release/OpenCV.dll: the prebuilt win64 DLL loaded by the application.
- src/UI.ui: the Qt Designer layout file; src/UI.py is generated from it.
- src/: main.py, the launcher scripts, and this document.
- venv/: Python virtual environment, created by step 1.
[Prerequisites]
- Operating system: Windows 11 — the bundled DLL is a win64 binary, so this example is Windows only.
- Python 3.7 to 3.10 — required by PySide2, which publishes no wheels for newer versions.
- Python packages: PySide2, numpy and opencv-python (installed automatically by step 1).
- A webcam, and a desktop environment because the example opens a window. No GPU required.
- Visual Studio, only if you want to rebuild the DLL from src/OpenCV/.
[Instructions]
Step 1: Create the virtual environment
Create the virtual environment and install src/requirements.txt (PySide2, numpy, opencv-python). Make sure the active Python is version 3.7 to 3.10 first, or the PySide2 install will fail.
Windows 11:
src\01_venv_create.bat
Ubuntu Linux 24.04:
bash src/01_venv_create.sh
Step 2: Activate the virtual environment
Activate the environment in the current shell. On Linux you must source the script so the activation stays in effect after it finishes.
Windows 11:
src\02_venv_activate.bat
Ubuntu Linux 24.04:
source src/02_venv_activate.sh
Step 3: Open the layout in Qt Designer
Open src/UI.ui in Qt Designer to see or edit the window visually. This step is optional if you only want to run the existing example.
Windows 11:
src\03_open_designer.bat
Ubuntu Linux 24.04:
bash src/03_open_designer.sh
Step 4: Compile the layout into Python
Convert src/UI.ui into src/UI.py. Run this every time you change the layout in Designer — the application imports the generated .py file, not the .ui file.
Windows 11:
src\04_ui_to_py.bat
Ubuntu Linux 24.04:
bash src/04_ui_to_py.sh
Step 5: Run the webcam application
Run the application. It loads the OpenCV DLL, opens the webcam, and shows the live image in the Qt window. Windows only, and a webcam must be connected.
Windows 11:
src\05_run.bat
Step 6: Remove the virtual environment
When you are finished, delete the venv/ folder to free up disk space. Re-run step 1 whenever you need the environment again.
Windows 11:
src\99_venv_clear.bat
Ubuntu Linux 24.04:
bash src/99_venv_clear.sh
[Usage Notes]
- Windows only: the application drives a bundled win64 DLL through ctypes windll, so step 5 fails at the DLL load on Linux and macOS. The Visual Studio project under src/OpenCV/ rebuilds the DLL.
- PySide2 ships wheels for Python 3.7 to 3.10 only — install one of those Pythons before 01_venv_create; a newer Python needs a port to PySide6.
- Frames arrive through a callback: the C++ side calls back into Python for every captured frame, so the capture loop stays in the DLL and the Qt window only has to draw.
- Edits made in Designer only take effect after step 4 regenerates src/UI.py.
- If the window stays black, another application is probably holding the webcam — close it and run step 5 again.
This SDK is built in AppForAI - AI Dev Tools.
Purchase license separately: USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.