October 23, 2023 (1y ago)
Detecting Empty Parking Spaces Using Computer Vision
Method 1: Histogram of Oriented Gradients (HOG)
- Feature extraction technique used for computer vision and image processing tasks
- Detects objects or patterns within images by capturing information about the distribution of local gradients
- Steps:
- Gradient computation
- Image cell division
- Histogram calculation
- Block normalization
- Descriptor formation
- Training and detection
Example Code for HOG Feature Extraction
Method 2: Convolutional Neural Network (CNN)
- Train a CNN object detector and slide it over the image to find all cars
- Accurate but not efficient as it scans the same image multiple times
- Can easily find cars rotated in different orientations
- Requires a lot more training data than a HOG-based object detector
Example Code for CNN Object Detection
Method 3: Newer Deep Learning Approaches
- Mask R-CNN, Faster R-CNN, or YOLO
- Combines the accuracy of CNNs with efficiency tricks
- Runs relatively fast on a GPU if there is enough training data
Example Code for Object Detection with YOLO
Detecting Empty Parking Spaces
- Use Intersection Over Union (IoU) to measure overlap between objects
- IoU calculated by finding the amount of pixels where two objects overlap and dividing it by the amount of pixels covered by both objects
- Object detection may not always work perfectly with live video
- To prevent incorrect detection, ensure a parking space remains free for several sequential frames of video
Example Code for IoU Calculation
Sending a Text
- Use Twilio to send SMS alerts when a parking space is free for several frames
- Sign up for a Twilio trial account, create a phone number, and get account credentials
- Install the Twilio Python client library:
Example Code for Sending SMS with Twilio
GitHub Code Link