Skip to content

818ajian/TrafficCountingTool

 
 

Repository files navigation

TrafficCountingTool

Tool to draw lines into images and count objects crossing those lines (using Python and Tkinter; depending on former generated tracking results)

To run the tool:

  • Install prerequisites and run the python script (counting_tool.py), or
  • just run the executable file (.exe file for windows; .app for mac will follow)

Please note:

  • This tool depends on former generated tracking result files. Have a look at this repository describing an approach to extract vehicle and pedestrian motion tracks from recorded videos using open-source software.
  • You can find example tracking result files here. The format per line of those files is:
    • [image_is, object_id, rectangle_x, rectangle_y, widht, height, object_class, not relevant, not relevant, not relevant]
      • Object classes: {1: 'person', 2: 'bicycle', 3: 'car', 4: 'motorcycle', 6: 'bus', 8: 'truck', 17: 'dog'}
      • rectangle_x and rectangle_y are representing the lower left corner of each rectangle

Prerequisites and used versions

  • Python 3.6
  • OpenCV 3.2
  • Pandas 0.19.2
  • Tkinter 8.6
  • openpyxl 2.4.1

Usage

  • For just trying out, you can find an image and tracking result files here.
  1. Start tool, select an image representing the cams perspective and set parameters. Default parameters are taken from the image (created at) and its path using python's os module.

  1. Select tracking result files and choose the object classes you want to count for.

  1. Draw all tracks (related to former chosen object classes). Drawing all relevant tracks helps to find best positions for the counting lines.

  1. Draw counting lines into image.
  • point p1 is the point of the line where you have started to draw the line. Accordingly p2 is the point where you have released the left mouse button.
  • if you look from point p1 to point p2 you will always find B at the left hand side and A at the right hand side

  1. Start intersection counting (can take a while depending off number of tracks and counting lines).

  1. Choose export granularity and save results to excel. For each chosen granularity you will find an separate excel sheet (aggregated accordingly) and if you have chosen "export raw data" than you will find an sheet for raw data (one line per intersection) too. If you select an existing excel file to export to, than new sheets will be added to it. Existing and equal named sheets will be overwritten.

Authors

Acknowledgments

About

Tool to draw lines into images and count objects crossing those lines (using Python and Tkinter; depending on former generated tracking results)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%