Skip to content

See movement patterns over time using Python and OpenCV

Notifications You must be signed in to change notification settings

andikarachman/Motion-Heatmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Motion Heatmap

This application is useful to see movement patterns over time. For example, it could be used to see the usage of entrances to a factory floor over time, or patterns of shoppers in a store.

Dependencies

  • opencv
  • numpy

You need the extra modules installed for the MOG background subtractor. The easiest way to install it was using:

pip install opencv-contrib-python

Command Format

$ python motion_heatmap.py [-h] -i INPUT -o OUTPUT

  • INPUT: path to input video
  • OUTPUT: path to output image.

How it works

The main APIs used in OpenCV are:

The application takes each frame and first applies background subtraction using the cv2.bgsegm.createBackgroundSubtractorMOG() object to create a mask. A threshold is then applied to the mask to remove small amounts of movement, and also to set the accumulation value for each iteration. The result of the threshold is added to an accumulation image (one that starts out at all zero and gets added to each iteration without removing anything), which is what records the motion. At the very end, a color map is applied to the accumulated image so it's easier to see the motion. This colored imaged is then combined with a copy of the first frame using cv2.addWeighted to accomplish the overlay.

Releases

No releases published

Packages

No packages published

Languages