View
project
<-- Back to Projects
Object Tracking and Counting Program

Project Status:

Complete

This computer program was made using C/C++ and OpenCV, an open computer vision library, to detect and track objects in a video. This allows the user to keep count of the objects passing a boundary line in a particular direction, without having to manually count them by hand. It utilizes image processing, by breaking up the video into its frames, to display boxes representing the objects being tracked, and the overall count transposed onto the video. Read the full report here: https://drive.google.com/file/d/14iUoZCZ_B4JZWvvwDSOx4Ob3F6qGNY9p/view?usp=drive_link

Project Proposal

The output of the program is fairly simple, where multiple pop up windows will be displayed when the program is run to show each stage of the image processing, as seen in Figure 1 below. This includes, the video after having undergone stages of threshold, contours, convex hulls, and addition of image blobs.

Programming with OpenCV

This program made use of 4 main library types: opencv2/core/core.hpp, opencv2/highgui/highgui.hpp, opencv2/imgproc/imgproc.hpp, and iostream. A key part of the prediction algorithm used to estimate the next position of the object being tracked is the weighted moving average (WMA) formula. Compared to the simple calculation of average, the WMA puts greater weight on most recent data, with weights decreasing as the data is further from the current position being predicted. This is done as shown below:

Output

To test the program, I altered various values of the conditions in the main.cpp to adjust the criteria for what possible blobs will be considered in the vector of actual blobs. In addition, I created pop-up windows for every stage of image processing, on top of the final output, using the imshow() function to create a new window. The order in which the output windows are shown are according to the stages they are processed from the raw video file.