A console/terminal demo of OpenCV image addition, supporting Windows 11 and Ubuntu Linux 24.04. It runs three operations in turn: scalar addition with cv2.add(img, value), a saturating brighten that clips instead of overflowing; image addition with cv2.add against a solid-color image; and weighted blending with cv2.addWeighted. Two example images ship under data/, and the three results are saved to model/add/. No GPU is involved.
[Folder Structure]
- CLAUDE.md / AGENT.md: program specification (identical content).
- CHANGELOG.md: change log.
- copyright.txt: copyright notice.
- data/: the example images Lena.png and sample.png.
- model/add/: the results add_scalar.png (scalar addition), add_image.png (addition with a solid-color image) and add_weighted.png (weighted blending).
- tool/tools.py: shared helpers.
- src/: the demo, the launcher scripts and this document.
- venv/: Python virtual environment, created by step 01.
[Prerequisites]
- Operating system: Windows 11 or Ubuntu Linux 24.04.
- Python 3 and pip.
- No GPU required; an ordinary CPU is enough.
[Instructions]
Step 1: Create the virtual environment
Delete the old venv/, create a fresh one and install the packages listed in src/requirements.txt. The script aborts loudly if pip fails.
Windows: src\01_venv_create.bat
Linux: bash src/01_venv_create.sh
Step 2: Activate the virtual environment
Activate the venv. On Linux, source the script.
Windows: src\02_venv_activate.bat
Linux: source src/02_venv_activate.sh
Step 3: Run the image-addition demo
Run the demo. Any extra arguments are forwarded to the program.
Windows: src\03_add.bat
Linux: bash src/03_add.sh
To use your own image and parameters, for example:
bash src/03_add.sh --source data/sample.png --value 60 --color 0,64,128 --alpha 0.5 --beta 0.5
Step 4: Remove the virtual environment
Delete the venv/ folder.
Windows: src\99_venv_clear.bat
Linux: bash src/99_venv_clear.sh
[Python Entry Point]
- src/opencv_add.py: [--source IMG] [--value 128] [--color B,G,R] [--alpha 0.7] [--beta 0.3] [--output-dir DIR] [--show]. The defaults are data/Lena.png, a scalar of +128, a solid color of BGR 128,128,0 and a blend of 0.7 and 0.3. Adding --show also opens the results in windows.
[References]
- OpenCV arithmetic operations tutorial: https://docs.opencv.org/4.x/d0/d86/tutorial_py_image_arithmetics.html
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.