0% found this document useful (0 votes)
8 views4 pages

NP-CP-1

Uploaded by

nani chkhenkeli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

NP-CP-1

Uploaded by

nani chkhenkeli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Numerical Analysis of hockey player tracking algorithm

Overview

Provided code implements a real-time object detection and tracking system. Core principles
behind the code are based on image processing techniques such as edge detection,
background subtraction, and centroid tracking. Goal is to analyze motion in video frames,
identify moving objects, track their paths, and compute their speed.

How the Code Works

1. Video Capture and Preprocessing

The code begins by reading frames from a video input.

OpenCV is used to capture each frame, which forms the input for the system.

Code converts each frame to grayscale and reduces noise using Gaussian blur.
This preprocessing step helps to minimize the complexity of the image, ensuring
that subsequent detection algorithms perform more efficiently.

2. Edge Detection using Sobel Operator

Sobel edge detection is applied to each frame. Sobel operator calculates the
gradient of the image intensity at each pixel, allowing the system to highlight
areas where significant changes in pixel intensity occur. These areas generally
correspond to edges in the objects within the scene.

The Sobel filter is used to detect edges in both the horizontal and vertical
directions. This is a good approach to detecting boundaries of moving objects, as
it enhances regions where significant motion is likely to be present.

3. Background Subtraction and Thresholding

Background subtraction plays a critical role in identifying moving objects. The


background model is updated continuously with each frame to track the
difference between the current frame and the previous one.

To highlight the moving parts of the frame, the code applies a binary thresholding
technique. This converts the image into a binary format, where the white areas
represent detected motion, and the black areas represent static or background
regions.

Contour Detection
Contours are detected from the thresholded binary image, refer to the boundaries
of the moving objects, which are typically formed from the regions marked in
white.

Each contour is a potential object in the scene. The code computes the centroid
(geometric center) of each contour, which represents the approximate center of
the object.

Centroid tracking helps keep track of the object’s position frame-to-frame.


Instead of tracking every pixel of an object, which is computationally expensive,
the code tracks only the centroid, simplifying the process.

4. Speed Calculation

Speed calculation is performed by measuring Euclidean distance traveled by each


object between frames.

frame rate helps to convert pixel-based movement into real-world speed.

To smooth out fluctuations in the calculated speed, especially from objects


moving sporadically, the code applies a moving average filter.

The moving average technique is a good way to handle real-time data processing
where speed variations may occur due to frame-to-frame inconsistencies or
transient object behavior.

1. Displaying Results

The code overlays the calculated speeds on the video feed using OpenCV. text is
drawn near each moving object, showing the speed in real-time. total number of
moving objects detected is also displayed, allowing users to track the number of
objects being monitored. also includes a bounding box around each detected
object to clearly indicate the area of interest.

Evaluation on Different Videos

Video 1: Top View with 10 Players (Works Well)

Reason for Success:

Since the camera is positioned directly above the players, their contours are
clearly visible, which allows the Sobel edge detection to identify sharp
boundaries.
Also, background subtraction works well because the motion of the players is
distinct and separated from the relatively static background.

Video 2: Horizontal View with Single Player (Fails)

Reason for Failure:

In a horizontal side view, the player's contours are less distinct compared to a
top-down view, making it harder for the tracking algorithm to differentiate the
player from the background.

background subtraction fail to distinguish the player from the background, the
tracking is less effective because the lack of multiple objects to differentiate may
cause the centroid tracking to either lose the player or mistakenly track the
background.

Since there are fewer objects in the scene, the tracking algorithm struggles to
maintain focus on the player, often leading to incorrect tracking or loss of the
player.
Conclusion

This approach successfully detects and tracks multiple moving objects in videos with
clear contrasts between the objects and the background. However, it faces challenges in
scenarios with complex backgrounds or a single object, where edge detection and
tracking should be reviewed and handled different way.

You might also like