Skip to main content

A computer vision application for automated countingof pedestrians and cyclists

Project description

Automated Walk Bike Counter

About

The City currently does bicycle and pedestrian counts via having a person manually count the number of cyclists and pedestrians that go through an intersection, either in person or by viewing a video recording.

However, thanks to advances in computer vision we can now automate that, allowing us to constantly count the number of pedestrians and cyclists, rather than sampling a (possibly not representative) time and location.

This project is a Python application that implements a computer vision algorithm developed by CSULA that allows you to run the pipeline on your own cameras feeds.

This approach allows cities and others to implement CV pedestrian and bicycle counting techniques on existing camera infrastructure.

Sponsors

This work has been generously sponsored by a grant from the Toyota Mobility Foundation (TMF).

Partners

CSULA

Dr. Mohammad Pourhomayoun, Moahmmad Vahedi, Haiyan Wang.

Los Angeles DOT/ITA

Hunter Owens, Ian Rose, Janna Smith, Anthony Lyons.

Goals

Allow us to know real-time active transportation counts for key corridors.

Requirements

This application requires a working Python environment capable of running Tensorflow. Either Tensorflow GPU or Tensorflow CPU can be used, but the latter is likely too slow for real-time application.

Installation

This application can run on environments both with and without GPUs. However, if a GPU is not available, it will likely run so slowly as to only be useful for testing/development. If you are running it with a GPU, you must already have the CUDA dynamic libraries installed and visible to the application.

The application comes with two conda environment specifications, one for machines with a GPU, and one for machines without. We assume you are installing the Python dependencies sugin conda. This is not required, but if you are installing with another tool, dependency manangement will likely be more difficult. Instructions for installation and running are as follows:

  1. Create a conda environment for the project. If running without GPUs, run
conda env create -f environment.yml

If running with GPUs, run

conda env create -f environment-gpu.yml

The given environment.yml files are known to work on at least some Linux, Windows, and Mac machines, though you may want to choose a custom Tensorflow distribution depending on your deployment.

  1. Activate the environment:
conda activate automated-walk-bike-counter
  1. Install the application into the environment by running
pip install .
  1. Launch the GUI by running automated-walk-bike-counter

Running the application

Generally speaking, the application takes a video source as input and counts pedestrians an cyclists that it sees in the video. It can produce two kinds of output:

  1. A new video that is the same as the input, but with boxes drawn around the identified objects.
  2. A comma-separated-variable (CSV) text file that has time-binned counts for the identified objects.

Each of these output files is placed next to the original input file.

The application has two interfaces: a graphical user interface (GUI), and a command line interface (CLI):

GUI

In order to run the GUI, you must have an X server running on your machine. This could be X11 on Mac OS or Linux, or Xming on Windows. You may need to set your DISPLAY environment variable for the application to find the running X server, i.e.

export DISPLAY=:0

Once you launch the application, you can run the algorithm with the following steps:

  1. Select a file using the File menu.
  2. Select which objects you want to track using the checkboxes in the left pane.
  3. Select an area of interest using the Tools menu (optional)
  4. Click the "Generate" button.

Command line usage

If you are running this application on a headless machine, or automating it in some way, you will likely not want to use the GUI, but instead drive it from the command line.

You can run it via the command line by using the cli argument:

automated-walk-bike-counter --cli True

Since this way of running the application doesn't have dialogs for selecting videos and other options, you will need to provide more command line arguments.

For instance, to run the algorithm on a local video file with CSV exports at one minute intervals, you should enter

automated-walk-bike-counter \
    --cli True \
    --file_name /path/to/your/video.mp4 \
    --input_type file \
    --save_periodic_counter True \
    --periodic_counter_interval 1

Configuration

The application is designed be be configured. The full list of configurable settings can be viewed by running automated-walk-bike-counter --help.

All variables can be set in one of three ways:

  1. Via command line argument.
  2. Via environment variable (available environment variables are listed in the --help output).
  3. Via config file.

If using a config file, you should add the settings in a .ini file, and point the application at the file by running

automated-walk-bike-counter --config /path/to/your/config.ini

An example config file can be found in config.example.ini.

Development

In order to develop this project, you should make an editable dev install after creating your environment:

pip install -e .[develop]

You should then install the pre-commit hooks which are used to enforce code style and lint for common errors:

pre-commit install

With these installed, all commits will get checked by the formatters and linters, and the commit will fail if these checks fail.

Note: the first time that you make a commit with these hooks pre-commit will do some setup work. This will take a few minutes. If you must, you can bypass the hooks by running git commit --no-verify.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

automated-walk-bike-counter-0.1.0.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file automated-walk-bike-counter-0.1.0.tar.gz.

File metadata

  • Download URL: automated-walk-bike-counter-0.1.0.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for automated-walk-bike-counter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e15d5ea77b1b1969aa9c2357f98c658bea045df13c334e029e1067b82ec48170
MD5 d11bfe90287c9e7f9a7c17ec4e1c48f8
BLAKE2b-256 48a00b5e73ae59a238aa1cc6db4083eaa2404de13e30038e46e6bf0df74b5bd4

See more details on using hashes here.

File details

Details for the file automated_walk_bike_counter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: automated_walk_bike_counter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for automated_walk_bike_counter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df25740bf67007d1e35caecbe9c89f0aaa6748dd1840ae9be5e0e1f9c8f9be01
MD5 4ade00afe625bf151a66060cbb48fbeb
BLAKE2b-256 7d41f994870aa6d376c80bda117bddb7789b05eb69d5f2b54c48ffcbc95a401b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page