A simple Flask application for image-based item recognition, leveraging OpenCV's ORB feature descriptor and a SQLite database for storing items and their associated images.
- CRUD Operations: Manage items with Create, Read, Update, and Delete functionalities.
- Multiple Images: Associate multiple images per item.
- Reference URL: Link each item to a reference URL.
- Blurriness Check: Ensure image clarity using Laplacian variance.
- ORB Descriptors: Utilize ORB feature descriptors for reliable feature matching.
- Descriptor Comparison: Compare new image descriptors against stored items.
- Threshold-Based Classification:
- High Confidence: Confident match found.
- Borderline: Prompt for more images.
- No Match: Notify the user of no match.
- Image Capture: Capture images via webcam or upload from desktop/mobile.
- Single-User Login: Secure login with hashed passwords (bcrypt).
- Session Management: Session-based authentication with configurable lockout after failed attempts.
- Backend: Python (Flask)
- Image Processing: OpenCV
- Database: SQLite
- Frontend: JavaScript, HTML/CSS, Jinja2
git clone https://github.com/Charisn/Image_recognition.git
cd Image_recognition
Ensure Python 3.8+ and pip
are installed, then run:
pip install -r requirements.txt
If requirements.txt
is missing, manually install key modules: flask
, python-dotenv
, opencv-python
, numpy
, bcrypt
, etc.
Create a .env
file in the project root:
SECRET_KEY=some-random-key
UPLOAD_FOLDER=static/uploads
MAX_CONTENT_LENGTH_MB=10
ALLOWED_USERNAME=defaultuser
ALLOWED_PASSWORD=defaultpass
MAX_LOGIN_TRIES=5
LOCKOUT_MINUTES=15
DB_PATH=database/items.db
PORT=443
DEBUG=1
Note:
PORT=443
implies HTTPS. For HTTP (e.g., port5000
), adjustPORT
accordingly.- On first run, the app auto-creates the database and uploads folders.
python app.py
Access the app at https://localhost:443 (or your configured host/port).
- Login: Go to
/login
and enter your credentials. - Add Item: Navigate to
/add
and submit the item's URL. - Capture Images: Provide 3 clear images:
- Blurriness Check: Ensures image clarity using Laplacian variance.
- ORB Descriptors: Generated and stored for feature matching.
- Completion: After successful uploads, the item is ready for recognition.
- Navigate to
/view
. - Capture/Upload an Image.
- Processing:
- Blurriness Check: Ensures image clarity.
- ORB Descriptor Computation: Extract features from the image.
- Descriptor Comparison: Compare against stored items.
- Results:
- High Confidence: Redirect to the item's URL.
- Borderline: Prompt for more images.
- No Match: Notify the user of no match.
Image_recognition/
├── app.py # Main Flask application
├── scripts.js # Client-side camera handling
├── templates/ # Jinja2 templates
│ ├── base.html
│ ├── index.html
│ ├── login.html
│ ├── add.html
│ ├── capture_images.html
│ ├── view.html
├── static/
│ └── uploads/ # Stored captured images
├── database/
│ └── items.db # SQLite database (auto-created)
├── .env # Environment config
├── requirements.txt # Project dependencies
└── README.md # Project documentation
-
Fork the repository
-
Create a feature branch
git checkout -b feature/new-stuff
-
Commit changes
git commit -m 'Add new feature'
-
Push to your branch
git push origin feature/new-stuff
-
Open a Pull Request
This project is open-source. Feel free to modify and use it as needed. Check the LICENSE
file for more details.
Charisn
Senior Software Engineer passionate about solving problems and exploring new technologies.
Questions or ideas? Open an issue or submit a pull request!