This project demonstrates a real-time system for recognizing a specific template (e.g., a special CNIC) in a video stream using OpenCV. The system leverages the SIFT (Scale-Invariant Feature Transform) algorithm for feature detection and FLANN (Fast Library for Approximate Nearest Neighbors) for matching.
- Real-time video processing with a webcam.
- Template matching using SIFT features.
- Homography computation to detect the template's position and orientation.
- FPS (frames per second) display for performance monitoring.
- Python 3.x
- OpenCV
- Install Python 3.x from Python.org.
- Install OpenCV library:
pip install opencv-python opencv-contrib-python
-
Ensure you have a template image named
template.pngin the working directory. -
Run the script:
python template_test_realtime.py
- Make sure you have Node.js installed.
- You need a simple HTTP server to run the
index.htmlfile due to browser security restrictions (accessing webcam, loading OpenCV.js). - Navigate to the project directory in your terminal.
- Install a simple server package (if you don't have one):
npm install -g http-server
- Start the server:
http-server . - Open your web browser and go to the URL provided by
http-server(usuallyhttp://127.0.0.1:8080orhttp://localhost:8080). - Ensure the
template.pngfile is present in the same directory. - Click the "Start Webcam" button.