Package: automated-walk-bike-counter
Automated Walk Bike CounterAboutThe 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 acomputer vision algorithmdeveloped 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.SponsorsThis work has been generously sponsored by agrantfrom the Toyota Mobility Foundation (TMF).PartnersCSULADr. Mohammad Pourhomayoun, Moahmmad Vahedi, Haiyan Wang.Los Angeles DOT/ITAHunter Owens, Ian Rose, Janna Smith, Anthony Lyons.GoalsAllow us to know real-time active transportation counts for key corridors.RequirementsThis 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.InstallationThis 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 suginconda.
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:Create a conda environment for the project. If running without GPUs, runcondaenvcreate-fenvironment.ymlIf running with GPUs, runcondaenvcreate-fenvironment-gpu.ymlThe givenenvironment.ymlfiles 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.Activate the environment:condaactivateautomated-walk-bike-counterInstall the application into the environment by runningpipinstall.Launch the GUI by runningautomated-walk-bike-counterRunning the applicationGenerally 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:A new video that is the same as the input, but with boxes drawn around the identified objects.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):GUIIn 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 yourDISPLAYenvironment variable for the application to
find the running X server, i.e.exportDISPLAY=:0Once you launch the application, you can run the algorithm with the following steps:Select a file using the File menu.Select which objects you want to track using the checkboxes in the left pane.Select an area of interest using the Tools menu (optional)Click the "Generate" button.Command line usageIf 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 thecliargument:automated-walk-bike-counter--cliTrueSince 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 enterautomated-walk-bike-counter \
    --cli True \
    --file_name /path/to/your/video.mp4 \
    --input_type file \
    --save_periodic_counter True \
    --periodic_counter_interval 1ConfigurationThe application is designed be be configured.
The full list of configurable settings can be viewed by runningautomated-walk-bike-counter --help.All variables can be set in one of three ways:Via command line argument.Via environment variable (available environment variables are listed in the--helpoutput).Via config file.If using a config file, you should add the settings in a.inifile,
and point the application at the file by runningautomated-walk-bike-counter--config/path/to/your/config.iniAn example config file can be found inconfig.example.ini.DevelopmentIn order to develop this project, you should make an editable dev install after creating your environment:pipinstall-e.[develop]You should then install the pre-commit hooks which are used to enforce code style
and lint for common errors:pre-commitinstallWith 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 hookspre-commitwill do some setup work.
This will take a few minutes. If you must, you can bypass the hooks by runninggit commit --no-verify.