|  | 
| 1 |  | -# Brute Force Image Search | 
| 2 | 1 | 
 | 
| 3 |  | -This project is a real-time brute force image search application that searches for related images of objects captured by a camera.  | 
| 4 |  | -It leverages computer vision techniques to find matching images from a predefined dataset. | 
|  | 2 | + | 
|  | 3 | +# Object Matching with CLIP & OpenCV | 
|  | 4 | + | 
|  | 5 | +## Overview | 
|  | 6 | + | 
|  | 7 | +This project implements a simple object matching system using OpenCV for webcam capture and OpenAI's CLIP model for image similarity detection. The goal is to open the camera feed, detect when an object from a small dataset is presented, and display the most similar image side-by-side in real time. | 
|  | 8 | + | 
|  | 9 | +--- | 
| 5 | 10 | 
 | 
| 6 | 11 | ## Features | 
| 7 | 12 | 
 | 
| 8 |  | -- Real-time object recognition using computer vision. | 
| 9 |  | -- Brute force search to find similar images in a dataset. | 
| 10 |  | -- Integration with camera feed for live searches. | 
| 11 |  | -- Simple and easy-to-use. | 
|  | 13 | +* Real-time webcam preview | 
|  | 14 | +* Efficient object matching using CLIP’s pretrained image embeddings | 
|  | 15 | +* Displays the closest matching dataset image next to the live camera feed when a match is found | 
|  | 16 | +* Lightweight solution tailored for small datasets (e.g., 5 images) | 
|  | 17 | +* Threshold tuning for balancing accuracy and detection sensitivity | 
|  | 18 | + | 
|  | 19 | +--- | 
|  | 20 | + | 
|  | 21 | +## Technologies Used | 
|  | 22 | + | 
|  | 23 | +| Technology       | Purpose                                                                                                        | | 
|  | 24 | +| ---------------- | -------------------------------------------------------------------------------------------------------------- | | 
|  | 25 | +| **OpenCV**       | Capture video from the webcam, process frames, and display results.                                            | | 
|  | 26 | +| **OpenAI CLIP**  | Compute semantic embeddings for images and measure similarity between the live camera feed and dataset images. | | 
|  | 27 | +| **PyTorch**      | Deep learning framework to run the CLIP model efficiently on CPU or GPU.                                       | | 
|  | 28 | +| **PIL (Pillow)** | Image preprocessing before feeding images to CLIP.                                                             | | 
|  | 29 | +| **NumPy**        | Handle array operations for image processing and similarity computations.                                      | | 
|  | 30 | + | 
|  | 31 | +--- | 
| 12 | 32 | 
 | 
| 13 |  | -## Getting Started | 
|  | 33 | +## Why These Technologies? | 
| 14 | 34 | 
 | 
| 15 |  | -To get started with the project, follow these steps: | 
|  | 35 | +* **OpenCV** is the de facto standard for real-time video and image processing in Python, providing easy access to camera streams and visualization tools. | 
|  | 36 | +* **CLIP** (Contrastive Language–Image Pretraining) is a state-of-the-art model that produces rich, semantic image embeddings without requiring additional training. This makes it ideal for small projects where retraining large models isn’t feasible. | 
|  | 37 | +* Using **CLIP** allows comparing visual similarity at a semantic level rather than just pixel matching or local features, improving robustness to lighting, angle, and minor variations. | 
|  | 38 | +* **PyTorch** provides a flexible backend for running CLIP efficiently, taking advantage of GPUs if available, but also running on CPU for smaller-scale projects. | 
|  | 39 | +* **PIL** is used to preprocess images to the format CLIP expects. | 
|  | 40 | +* **NumPy** enables efficient numerical operations needed for similarity scoring. | 
| 16 | 41 | 
 | 
| 17 |  | -1. **Prerequisites**: Make sure you have the required libraries and dependencies installed. | 
|  | 42 | +--- | 
| 18 | 43 | 
 | 
| 19 |  | -2. **Configuration**: Configure the project settings and dataset for image search. | 
|  | 44 | +## Setup and Usage | 
| 20 | 45 | 
 | 
| 21 |  | -3. **Run the Application**: Execute the application to start live image searching. | 
|  | 46 | +### Requirements | 
| 22 | 47 | 
 | 
| 23 |  | -   ALL ABOVE POINTS ARE SO IMPORTANT TO EXECUTE,PLEASE KEEP A NOTE OF THEM !! | 
| 24 |  | -   ALL THE BEST ! | 
|  | 48 | +* Python 3.7+ | 
|  | 49 | +* pip packages: `opencv-python`, `torch`, `openai-clip`, `numpy`, `Pillow` | 
|  | 50 | + | 
|  | 51 | +### Installation | 
| 25 | 52 | 
 | 
| 26 | 53 | ```bash | 
|  | 54 | +pip install opencv-python torch openai-clip numpy Pillow | 
|  | 55 | +``` | 
|  | 56 | + | 
|  | 57 | +### Running the Program | 
|  | 58 | + | 
|  | 59 | +1. Place your dataset images in a folder (e.g., `testimg/`). | 
|  | 60 | +2. Run the main script: | 
|  | 61 | + | 
|  | 62 | +   ```bash | 
|  | 63 | +   python BFSearch.py | 
|  | 64 | +   ``` | 
|  | 65 | +3. The camera window will open. | 
|  | 66 | +4. Place an object from your dataset in front of the camera. | 
|  | 67 | +5. When a matching object is detected, its image will be displayed side-by-side with the camera feed. | 
|  | 68 | + | 
|  | 69 | +--- | 
|  | 70 | + | 
|  | 71 | +## Limitations & Future Work | 
|  | 72 | + | 
|  | 73 | +* The matching threshold might require tuning depending on lighting and dataset quality. | 
|  | 74 | +* Works best with small datasets; larger datasets may require optimization. | 
|  | 75 | +* Future improvements may include more advanced object detection or real-time bounding boxes. | 
|  | 76 | +* Integration with GUI frameworks for better user interaction. | 
| 27 | 77 | 
 | 
0 commit comments