Skip to content

A Flask-based image recognition web application that allows users to register items with images and identify them later using OpenCV's ORB feature matching. Secure login, image validation, and real-time recognition are built-in for seamless item management.

License

Notifications You must be signed in to change notification settings

Charisn/Image_recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Recognition (Flask + OpenCV + SQLite)

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.

🚀 Features

Item Management

  • 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.

Image Processing

  • Blurriness Check: Ensure image clarity using Laplacian variance.
  • ORB Descriptors: Utilize ORB feature descriptors for reliable feature matching.

Recognition System

  • 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.

User Interface

  • Image Capture: Capture images via webcam or upload from desktop/mobile.

Authentication

  • Single-User Login: Secure login with hashed passwords (bcrypt).
  • Session Management: Session-based authentication with configurable lockout after failed attempts.

🛠️ Tech Stack

  • Backend: Python (Flask)
  • Image Processing: OpenCV
  • Database: SQLite
  • Frontend: JavaScript, HTML/CSS, Jinja2

📂 Table of Contents

🏁 Getting Started

Clone the Repo

git clone https://github.com/Charisn/Image_recognition.git
cd Image_recognition

Install Dependencies

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.

Environment Variables

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., port 5000), adjust PORT accordingly.
  • On first run, the app auto-creates the database and uploads folders.

Run the Application

python app.py

Access the app at https://localhost:443 (or your configured host/port).

🔎 How It Works

Item Addition Workflow

  1. Login: Go to /login and enter your credentials.
  2. Add Item: Navigate to /add and submit the item's URL.
  3. Capture Images: Provide 3 clear images:
    • Blurriness Check: Ensures image clarity using Laplacian variance.
    • ORB Descriptors: Generated and stored for feature matching.
  4. Completion: After successful uploads, the item is ready for recognition.

Recognition Workflow

  1. Navigate to /view.
  2. Capture/Upload an Image.
  3. Processing:
    • Blurriness Check: Ensures image clarity.
    • ORB Descriptor Computation: Extract features from the image.
    • Descriptor Comparison: Compare against stored items.
  4. Results:
    • High Confidence: Redirect to the item's URL.
    • Borderline: Prompt for more images.
    • No Match: Notify the user of no match.

📁 Project Structure

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

🤝 Contributing

  1. Fork the repository

  2. Create a feature branch

    git checkout -b feature/new-stuff
  3. Commit changes

    git commit -m 'Add new feature'
  4. Push to your branch

    git push origin feature/new-stuff
  5. Open a Pull Request

📜 License

This project is open-source. Feel free to modify and use it as needed. Check the LICENSE file for more details.

👤 Author

Charisn

Senior Software Engineer passionate about solving problems and exploring new technologies.

Questions or ideas? Open an issue or submit a pull request!

About

A Flask-based image recognition web application that allows users to register items with images and identify them later using OpenCV's ORB feature matching. Secure login, image validation, and real-time recognition are built-in for seamless item management.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published