Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

ArUco-Based Sports Tracking

A small computer-vision toolkit that detects ArUco markers, performs a planar (homography) transform, and tracks colored objects (e.g., a player and a ball) in video. The transformed coordinates are overlaid onto a soccer-field background and basic in-game events (goal/throw-in/goal-kick) are inferred from positions.

Built with OpenCV and NumPy

Installation

python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

Rectify an image

main_code requires ArUco markers with IDs 0–3 and writes a 2100×2970 rectified image:

python main_code path/to/input.jpg path/to/output.png

Features

  • ArUco detection using OpenCV’s cv2.aruco (DICT_4X4_50).

  • Homography / perspective transform from the camera view into a fixed 640×416 pitch plane.

  • Color-based segmentation with interactive HSV trackbars for two objects (player & ball).

  • Coordinate smoothing via a Gaussian kernel to stabilize trajectories.

  • Event logic (GOAL/THROW-IN/GOAL KICK) from transformed ball coordinates.

Structure

  • testing.py -> Track a yellow “player” and orange “ball” in a video via HSV + contours, use ArUco markers to compute a homography, project their positions onto a soccer-field image to draw motion trails, and display/save the live results

  • main_code -> Detects ArUco markers with IDs 0–3 in an image, computes a homography to a fixed 2100×2970 plane, and saves the rectified result

  • minimum_bounding_rect -> Threshold yellow regions, find contours, pick the largest one whose rotated box has an aspect ratio between 2 and 3.5, draw that box on the image, and display it

  • erode 'n dilate -> Interactively threshold a yellow color range with HSV trackbars, generate its mask, visualize the original/mask, and show the effects of erosion and dilation on both

  • detect_arucos -> Detect four specific ArUco markers (IDs 0–3), map their corners, warp the image onto a 2100×2970 plane, save the rectified result and print detection/transform timings

Additionally: Photos of items and tools used

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages