A Python GUI tool for detecting objects in images using computer vision techniques. Users can select a Region of Interest (ROI) and run detection methods (template matching, color segmentation, or edge detection) with instant visual feedback. This project was developed as a student assignment, but anyone interested in image processing or OpenCV is welcome to use or modify it.
- Graphical Interface: Easy-to-use Python/Tkinter GUI.
- ROI Selection: Draw a rectangle or polygon to select the target object.
- Multiple Detection Methods:
- Template Matching: Finds objects by comparing patterns (grayscale/color).
- Color Segmentation: Detects objects by color similarity (HSV/BGR).
- Edge Detection: Finds objects by contours and shapes.
- Image Preprocessing: Adjust brightness, contrast, blur, and more.
- Parameter Controls: Fine-tune detection thresholds, color tolerances, and more.
- Visual Results: Shows detected objects and generates a detection report.
- Load Image
Click "Load Image" and choose a file (jpg, png, bmp, etc). - Select ROI
Use the mouse to draw a rectangle or polygon around the target object. - Choose Detection Method
Select template matching, color segmentation, or edge detection from the sidebar. - Adjust Parameters
Set detection thresholds, color tolerance, or edge settings (Canny filter). - Detect Objects
Click "Apply Detection" to run the algorithm. - View Results
The detected objects will be highlighted in the image, and a report of detected objects will be shown.
This project requires Python 3 and the following packages:
opencv-pythonpillownumpy
Install dependencies with pip:
pip install opencv-python pillow numpyRun the program:
python main.py- Detects objects by comparing the ROI with the rest of the image.
- Supports grayscale or color pattern matching.
- Options for rotation and scale invariance.
- Detects objects matching a color range (HSV/BGR).
- Adjustable color tolerance and area filtering.
- Uses Canny edge detection to find contours.
- Adjustable low/high threshold and area filtering.
After running detection, the GUI displays:
- The original image with detected objects highlighted.
- Detection Report:
- Shows the total number of objects detected.
- Lists object labels, areas, and methods used.
- Example:
TEMPLATE: 2 found Detected Objects (by label): Label 1: 2432 px Label 2: 2671 px Threshold: 0.65 Method: grayscale
- Debug info for further analysis.
You can also include a screenshot of the output window, showing the image and report side-by-side.
- Uses OpenCV for image processing and detection algorithms.
- Assignment for students, but open for anyone interested in computer vision or Python GUI development.
This project is for educational purposes. See LICENSE for details (if available).
Feel free to fork and submit pull requests or issues. Suggestions and improvements are welcome!