iOS app that counts vehicles on real-time.
Clone or download
Pull request Compare This branch is 1 commit ahead of Ma-Dan:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
YOLOv3 CoreML model

Swift Real-time Traffic Counter

The purpose of this project is to use iPhone's camera and processing capabilities to count vehicles on a street or road on real-time.

This repo was forked and modified from hollance/YOLO-CoreML-MPSNNGraph and Ma-Dan/YOLOv3-CoreML.

These are the changes I made:

  1. Included mattt/Surge matrix library.
  2. Migrated Hungarian algorithm from its Python version.
  3. Migrated Kalman Filter from its Python version.
  4. Migrated SORT algorithm from its Python version.
  5. Used SORT algorithm to track detected objects trajectories.
  6. Added an interactive line to define an edge.
  7. Count trajectories that overpass the edge.

Pending work

  1. Improve accuracy on YOLO's object detection.
  2. Complete SORT, Kalman Filter and Hungarian algorithm migration to Python.
  3. Fix edge line on space (like new Apple's Measure app does)
  4. Count different types of objects

Quick Start

  1. Extract YOLOv3 CoreML model in YOLOv3 CoreML model folder and copy to YOLOv3-CoreML/YOLOv3-CoreML folder.
  2. Open the xcodeproj file in Xcode 9 and run it on a device with iOS 11 or better installed.

About YOLO

YOLO is an object detection network. It can detect multiple objects in an image and puts bounding boxes around these objects. Read Matthijs Hollemans's blog post to learn more about how it works.

About SORT

SORT is a simple online and realtime tracking algorithm for 2D multiple object tracking in video sequences. Check Alex Bewley's SORT repository to learn how it works.


Surge is a Swift library that uses the Accelerate framework to provide high-performance functions for matrix math, digital signal processing, and image manipulation. Check Mattt's SURGE repository to learn how it works.



  title={YOLO9000: Better, Faster, Stronger},
  author={Redmon, Joseph and Farhadi, Ali},
  journal={arXiv preprint arXiv:1612.08242},


  author={Bewley, Alex and Ge, Zongyuan and Ott, Lionel and Ramos, Fabio and Upcroft, Ben},
  booktitle={2016 IEEE International Conference on Image Processing (ICIP)},
  title={Simple online and realtime tracking},
  keywords={Benchmark testing;Complexity theory;Detectors;Kalman filters;Target tracking;Visualization;Computer Vision;Data Association;Detection;Multiple Object Tracking},