A Django-based web application that provides real-time video streaming with various image processing features including grayscale conversion, binary thresholding, and distance measurement capabilities.
- Live webcam video feed streaming through a web browser
- Smooth video capture at 900x600 resolution
- Motion JPEG encoding for efficient video transmission
- Normal View: Standard webcam feed with interactive measurement tools
- Grayscale Mode: Convert live video to grayscale
- Binary Mode: Apply binary thresholding (black and white) to the video stream
- Click on the video canvas to mark two points
- Automatic distance calculation between marked points
- Visual representation with dotted lines connecting points
- Real-time coordinate tracking with mouse movement
- Record and manage multiple measurements in a table
- Delete or select previous measurements
- Pre-configured with Haar Cascade classifiers for face detection
- Deep learning models for face mask detection
- Caffe model files for advanced face recognition
- Backend: Django 3.0.5
- Computer Vision: OpenCV (opencv-python 4.2.0.34)
- Machine Learning: TensorFlow 2.3.0
- Image Processing:
- NumPy 1.18.2
- Pillow 7.1.1
- imutils 0.5.3
- Frontend:
- Bootstrap 3.4.1
- jQuery 3.5.1
- HTML5 Canvas API
- Database: SQLite3
- Python 3.x
- Webcam/Camera device
- pip package manager
-
Clone the repository
git clone https://github.com/Buddhima-JD3/Image-Processing.git cd Image-Processing -
Create a virtual environment (recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirement.txt
-
Run database migrations
python manage.py migrate
-
Start the development server
python manage.py runserver
-
Access the application
- Open your web browser and navigate to:
http://127.0.0.1:8000/ - Allow camera permissions when prompted
- Open your web browser and navigate to:
- Launch the application and grant camera access
- The main page displays your live webcam feed
- Click on the video canvas to mark the first point (a blue circle appears)
- Click again to mark the second point
- A dotted line connects the two points with the calculated distance
- The measurement is automatically saved in the records table
- Click a third time to clear and start a new measurement
- Click "Gray Scale" button to switch to grayscale view
- Click "Binary" button to switch to binary threshold view
- Each mode has its own dedicated page with the respective video filter
- Delete: Click the red (×) button to remove a measurement from the table
- Select: Click the green (✓) button to visualize a previous measurement on the canvas
Image-Processing/
│
├── face_detector/ # Face detection models and data
│ ├── deploy.prototxt # Caffe model configuration
│ ├── mask_detector.model # Face mask detection model
│ └── res10_300x300_ssd_iter_140000.caffemodel
│
├── opencv_haarcascade_data/ # Haar Cascade classifiers
│ └── haarcascade_frontalface_default.xml
│
├── streamapp/ # Main application
│ ├── camera.py # Video capture and processing classes
│ ├── views.py # Django views for handling requests
│ ├── urls.py # URL routing
│ ├── templates/streamapp/ # HTML templates
│ │ ├── home.html # Main interface
│ │ ├── grey.html # Grayscale mode
│ │ └── binary.html # Binary mode
│ └── ...
│
├── video_stream/ # Django project settings
│ ├── settings.py # Project configuration
│ ├── urls.py # Root URL configuration
│ └── wsgi.py # WSGI application
│
├── manage.py # Django management script
├── requirement.txt # Python dependencies
└── db.sqlite3 # SQLite database
- VideoCamera: Captures and streams normal video feed
- GreyVideoCamera: Converts video to grayscale using
cv2.cvtColor() - BinaryVideoCamera: Applies binary threshold to create black and white images
index: Main page with normal video and measurement toolsgrey_scale_page: Grayscale video pagebinary_scale_page: Binary threshold video pagevideo_feed: Streaming endpoint for normal videogrey_scale: Streaming endpoint for grayscale videobinary_scale: Streaming endpoint for binary video
/- Main application page/video_feed- Normal video stream/grey_scale_page- Grayscale mode page/grey_scale- Grayscale video stream/binary_scale_page- Binary mode page/binary_scale- Binary video stream
Key packages from requirement.txt:
- Django 3.0.5 - Web framework
- opencv-python 4.2.0.34 - Computer vision library
- TensorFlow 2.3.0 - Machine learning framework
- NumPy 1.18.2 - Numerical computing
- Pillow 7.1.1 - Image processing
- imutils 0.5.3 - OpenCV convenience functions
- Chrome (recommended)
- Firefox
- Edge
- Safari (with camera permissions)
- Make sure your camera is not being used by another application
- The application requires camera permissions to function
- For production deployment, update
SECRET_KEYinsettings.pyand setDEBUG=False - Configure
ALLOWED_HOSTSfor production environments
The codebase includes pre-configured models for:
- Face mask detection
- Face recognition using deep learning
- Advanced image processing pipelines
This project is available for educational and development purposes.
Feel free to fork this repository and submit pull requests for any improvements or bug fixes.
Camera not working?
- Ensure camera permissions are granted in your browser
- Check if another application is using the camera
- Verify the camera device is properly connected
Dependencies installation failing?
- Make sure you're using Python 3.x
- Try upgrading pip:
pip install --upgrade pip - Install system dependencies for OpenCV if on Linux
Server not starting?
- Check if port 8000 is available
- Ensure all migrations are applied:
python manage.py migrate - Verify virtual environment is activated