/Object-Trajectory-Prediction

The color finder in OpenCV with HSV values could highlight the targeted object, the ball, among the rest of objects. Additionally, the polynomial curve of its motion in future was predicted, and this could be a turning point for creating a flying hoop.

Primary LanguagePython

Project Name: Moving Basketball Hoop

Computer vision extends to several actions like object trajectory prediction. By OpenCV library, the color finder with HSV values could highlight the targeted object, the ball, among the rest of the objects.

This aided to assign the location of the ball's center point in (x,y) coordinates and was saved to be connected. Accordingly, the polynomial curve of its motion in the future was predicted (shown below), and this could be a turning point for creating a flying hoop. Moreover, this formed a path to knowing whether the ball will be shotted inside the traditional fixed hoop or not.

Capture for the model

Weakness point

The weakness point is contouring any object with the same color as a ball (shown below as the basketball hoop was detected), and this can cause errors within the fitting polynomial curve.

image

Solution of weakness point

I solved this error by taking the greatest area in the contouring. To illustrate, both the hoop and the ball had the same color; however, the curve was associated with ball center because the ball consumed a greater area from the pixels in the video frames.

Mechanical design

The aim is to implement an H-bot gantry design attached to a basketball hoop that moves in XY plan to catch the ball. I am responsible for the software part: ball trajectory prediction. In this stage, I am searching for the polynomial fitting equation in 2D and the motion of a curve in 3D.

Problems

The complex problem is that I had to approximate the single 2D images into the 3D position. This decision was because the design of H-bot gantry is moving in XY plan, and the ball is projected from the Z axis that makes an angle with X and Y axes.

Procedures

1. Ball detection with its center at a position vector (X,Y,Z)
2. Plotting the motion of ball in a 3D graph with matplotlib 
3. Searching for motion in a 3D curve to predict an equation for the polynomial curve of the ball motion 

Step 1 was done as shown below

image image

Step 2 and 3 are (in progress)

The current stage is for searching for the object trajectory prediction in 3D motion as it is one of the most important and complex topics in the computer vision field.