File size: 1,372 Bytes
b43901b
e80a5ff
7f3146d
b43901b
 
92f6d1f
 
b43901b
e80a5ff
 
b43901b
 
7f3146d
b43901b
7f3146d
 
b43901b
7f3146d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92f6d1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: ObjectDetection
emoji: πŸš—
colorFrom: red
colorTo: red
sdk: streamlit
app_file: src/streamlit_app.py
pinned: false
short_description: Detect and count cars/trucks in images (cvlib + OpenCV).
license: mit
---

# πŸš— Vehicle Counter – Object Detection App

This project uses computer vision to detect and count vehicles in an image.
A pre-trained object detection model from **cvlib** (YOLO) is used to identify cars and trucks.

The results are saved as:
- an output image with bounding boxes (`detected.jpg`)
- a JSON file with the object counts (`results.json`)

---

## πŸ” Features
- Upload an image (JPG / PNG / WEBP)
- Detect vehicles using cvlib and OpenCV
- Count cars and trucks automatically
- Save results as JSON
- Display detected image in a Streamlit app

---

## 🧠 How it works
1. The user uploads an image
2. Objects are detected using `cvlib.detect_common_objects`
3. Bounding boxes are drawn on the image
4. The number of cars and trucks is counted
5. Results are saved to `src/results.json` and `src/detected.jpg`

---

## ▢️ Run locally

```bash
pip install -r requirements.txt
streamlit run app.py

πŸ“ Project Structure
.
β”œβ”€β”€ app.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── src/
    β”œβ”€β”€ results.json
    └── detected.jpg

πŸ“Œ Output Example
{
  "cars": 11,
  "trucks": 3
}

Author

Enes Yamac