An open API service indexing awesome lists of open source software.

https://github.com/duyet/opencv-car-detection

OpenCV Python program for Vehicle detection
https://github.com/duyet/opencv-car-detection

Last synced: about 1 year ago
JSON representation

OpenCV Python program for Vehicle detection

Awesome Lists containing this project

README

          

# opencv-car-detection
OpenCV Python program for Vehicle detection

```python
import cv2
from matplotlib import pyplot as plt

car_cascade = cv2.CascadeClassifier('cars.xml')
img = cv2.imread('car3.jpg', 1)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Detect cars
cars = car_cascade.detectMultiScale(gray, 1.1, 1)

# Draw border
for (x, y, w, h) in cars:
cv2.rectangle(img, (x,y), (x+w,y+h), (0,0,255), 2)
ncars = ncars + 1

# Show image
plt.figure(figsize=(10,20))
plt.imshow(img)
```

## Demo

![car2.jpg](car2.jpg)

## Result

![result_car2.png](result_car2.png)