# ahmetozlu/vehicle_counting_tensorflow architecture

> Architecture diagram of the GitHub repository ahmetozlu/vehicle_counting_tensorflow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmetozlu/vehicle_counting_tensorflow
- Repository: https://github.com/ahmetozlu/vehicle_counting_tensorflow

## Overview

This is a video-based vehicle detection, tracking, and traffic-measurement sample. A user starts the main program with a display or video-writing mode; it reads the supplied video, runs object detection, and sends detections to visualization and measurement logic, which produce annotated frames and CSV measurements. Documented capabilities also include approximate color, direction, speed, and size estimates, plus cropped vehicle images. The graph follows the sampled calls and README; some visualization internals and documented capabilities are not fully shown in the excerpts.

Main entry points: [`vehicle_detection_main.py`](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/vehicle_detection_main.py) (Video pipeline), [`utils/visualization_utils.py`](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/visualization_utils.py) (Detection visualization), [`utils/color_recognition_module/color_recognition_api.py`](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/color_recognition_module/color_recognition_api.py) (Color recognition), [`utils/label_map_util.py`](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/label_map_util.py) (Label utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Video processing"]
  node_main["Video pipeline"]
  node_input["Source video<br/>[input_video.mp4]"]
end

subgraph group_detect["Detection and labels"]
  node_model["SSD model"]
  node_labels["Label map"]
  node_labelutil["Label utilities<br/>[label_map_util.py]"]
  node_proto["Label proto"]
end

subgraph group_analysis["Vehicle analysis"]
  node_visual["Detection visualization"]
  node_speed["Speed and direction"]
  node_colorapi["Color recognition"]
  node_crop["Center crop<br/>[crop_image.py]"]
  node_histogram["Color features"]
  node_knn["KNN classifier<br/>[knn_classifier.py]"]
end

subgraph group_results["Outputs"]
  node_saver["Vehicle image saver<br/>[image_saver.py]"]
  node_csv[("Traffic measurements")]
  node_vehicles[("Vehicle crops")]
  node_render["Frame output"]
end

node_user(("CLI user"))

node_user -->|"runs mode"| node_main
node_main -->|"reads video"| node_input
node_main -->|"loads model"| node_model
node_main -->|"selects labels"| node_labels
node_main -->|"loads categories"| node_labelutil
node_labelutil -->|"parses labels"| node_proto
node_main -->|"passes detections"| node_visual
node_visual -->|"estimates motion"| node_speed
node_visual -->|"requests color"| node_colorapi
node_colorapi -->|"crops center"| node_crop
node_colorapi -->|"extracts features"| node_histogram
node_colorapi -->|"classifies color"| node_knn
node_speed -->|"saves vehicle crop"| node_saver
node_saver -->|"writes images"| node_vehicles
node_main -->|"writes measurements"| node_csv
node_main -->|"displays or writes frames"| node_render
node_visual -->|"returns measurement row"| node_csv

click node_main "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/vehicle_detection_main.py"
click node_input "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/input_video.mp4"
click node_model "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb"
click node_labels "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/data/mscoco_label_map.pbtxt"
click node_labelutil "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/label_map_util.py"
click node_proto "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/protos/string_int_label_map_pb2.py"
click node_visual "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/visualization_utils.py"
click node_speed "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/speed_and_direction_prediction_module/speed_prediction.py"
click node_colorapi "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/color_recognition_module/color_recognition_api.py"
click node_crop "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/image_utils/crop_image.py"
click node_histogram "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/color_recognition_module/color_histogram_feature_extraction.py"
click node_knn "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/color_recognition_module/knn_classifier.py"
click node_saver "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/image_utils/image_saver.py"
click node_csv "https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/traffic_measurement.csv"
click node_vehicles "https://github.com/ahmetozlu/vehicle_counting_tensorflow/tree/master/detected_vehicles"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_input,node_user toneBlue
class node_model,node_labels,node_labelutil,node_proto toneAmber
class node_visual,node_speed,node_colorapi,node_crop,node_histogram,node_knn toneMint
class node_saver,node_csv,node_vehicles,node_render toneRose
```

## Components

### Video processing

- [Video pipeline](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/vehicle_detection_main.py): `vehicle_detection_main.py`
- [Source video](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/input_video.mp4): `input_video.mp4`

### Detection and labels

- [SSD model](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb): `ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb`
- [Label map](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/data/mscoco_label_map.pbtxt): `data/mscoco_label_map.pbtxt`
- [Label utilities](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/label_map_util.py): `utils/label_map_util.py`
- [Label proto](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/protos/string_int_label_map_pb2.py): `protos/string_int_label_map_pb2.py`

### Vehicle analysis

- [Detection visualization](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/visualization_utils.py): `utils/visualization_utils.py`
- [Speed and direction](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/speed_and_direction_prediction_module/speed_prediction.py): `utils/speed_and_direction_prediction_module/speed_prediction.py`
- [Color recognition](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/color_recognition_module/color_recognition_api.py): `utils/color_recognition_module/color_recognition_api.py`
- [Center crop](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/image_utils/crop_image.py): `utils/image_utils/crop_image.py`
- [Color features](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/color_recognition_module/color_histogram_feature_extraction.py): `utils/color_recognition_module/color_histogram_feature_extraction.py`
- [KNN classifier](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/color_recognition_module/knn_classifier.py): `utils/color_recognition_module/knn_classifier.py`

### Outputs

- [Vehicle image saver](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/utils/image_utils/image_saver.py): `utils/image_utils/image_saver.py`
- [Traffic measurements](https://github.com/ahmetozlu/vehicle_counting_tensorflow/blob/master/traffic_measurement.csv): `traffic_measurement.csv`
- [Vehicle crops](https://github.com/ahmetozlu/vehicle_counting_tensorflow/tree/master/detected_vehicles): `detected_vehicles`
- **Frame output**

### Other components

- **CLI user**

## Connections

- CLI user → Video pipeline: runs mode (evidence: `README.md`)
- Video pipeline → Source video: reads video (evidence: `vehicle_detection_main.py`)
- Video pipeline → SSD model: loads model (evidence: `vehicle_detection_main.py`)
- Video pipeline → Label map: selects labels (evidence: `vehicle_detection_main.py`)
- Video pipeline → Label utilities: loads categories (evidence: `vehicle_detection_main.py`)
- Label utilities → Label proto: parses labels (evidence: `utils/label_map_util.py`)
- Video pipeline → Detection visualization: passes detections (evidence: `vehicle_detection_main.py`)
- Detection visualization → Speed and direction: estimates motion (evidence: `utils/visualization_utils.py`)
- Detection visualization → Color recognition: requests color (evidence: `utils/visualization_utils.py`)
- Color recognition → Center crop: crops center (evidence: `utils/color_recognition_module/color_recognition_api.py`)
- Color recognition → Color features: extracts features (evidence: `utils/color_recognition_module/color_recognition_api.py`)
- Color recognition → KNN classifier: classifies color (evidence: `utils/color_recognition_module/color_recognition_api.py`)
- Speed and direction → Vehicle image saver: saves vehicle crop (evidence: `utils/speed_and_direction_prediction_module/speed_prediction.py`)
- Vehicle image saver → Vehicle crops: writes images (evidence: `utils/image_utils/image_saver.py`)
- Video pipeline → Traffic measurements: writes measurements (evidence: `vehicle_detection_main.py`)
- Video pipeline → Frame output: displays or writes frames (evidence: `vehicle_detection_main.py`)
- Detection visualization → Traffic measurements: returns measurement row
