A console/terminal demo of the OpenCV Canny edge detector, supporting Windows 11 and Ubuntu Linux 24.04. The input is smoothed with a Gaussian blur to suppress noise, converted to grayscale, and run through cv2.Canny. Canny uses two thresholds: gradients above the high threshold are edges, those below the low threshold are discarded, and the ones in between are kept only when they connect to a confirmed edge. Three example images ship under data/ (Lena, SC-150 and sample), and the results are saved to model/canny/. 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, SC-150.png and sample.png.
  • model/canny/: the results gray.png (the blurred grayscale image) and canny.png (the edge map); the Lena examples are included.
  • 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 edge-detection demo

Run the Canny edge-detection demo. Any extra arguments are forwarded to the program.

 

Windows: src\03_canny.bat

Linux: bash src/03_canny.sh

To use your own image and thresholds, for example:

bash src/03_canny.sh --source data/SC-150.png --low 50 --high 150

 

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/canny.py: [--source IMG] [--blur-kernel 7] [--low 10] [--high 100] [--output-dir DIR] [--show]. The defaults are data/Lena.png, a 7×7 Gaussian blur and Canny thresholds of 10 and 100. It saves gray.png (the blurred grayscale image) and canny.png (the edge map) to model/canny/; --show also opens the results in windows. --blur-kernel must be odd.

[References]

 

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.