This project implements an object recognition tool using computer vision techniques. The tool uses feature detectors and descriptors to detect and recognize objects in live video frames. It supports two feature detection algorithms: BRISK and SURF.
- Python 3.x
- OpenCV library (
opencv-python
,opencv-contrib-python
) - Numpy
-
Install the necessary dependencies:
pip install opencv-python opencv-contrib-python numpy
-
Run the
main.py
file to start object recognition from your webcam:python main.py
-
The program will detect the object (defined in the
img.png
training image) and display it on the webcam feed with a bounding box around the object.
__init__(self, detector)
: Initializes the object recognizer with the specified feature detector (BRISK or SURF).get_keypoints(self, _img)
: Detects keypoints in the provided image.get_descriptor(self, _img, _keypoints)
: Extracts descriptors for the detected keypoints.match(_d1, _d2)
: Matches descriptors between the training image and the frame.calculate_fps(_frame_number, _time)
: Calculates and returns the FPS of the webcam feed.detect_object(_training_image, _training_keypoints, _frame_keypoints, _filtered_matches)
: Detects the object from the frame using homography and matches.
- The main function sets up the recognizer, processes video frames from the webcam, and matches them to the training image.
- Description: Loaded a training image (
img.png
) and tested the system using a webcam. - Expected Outcome: The tool should detect and highlight the object in the webcam feed with a bounding box.
- Actual Outcome: The object was successfully detected, and the bounding box was drawn around it.
- Description: Tested FPS calculation by displaying the FPS on the webcam feed.
- Expected Outcome: FPS should be calculated and displayed on the screen.
- Actual Outcome: FPS was correctly displayed and updated in real time.
This tool is provided under the MIT license.