Week 2. Extracting the frames

1 minute read

Extracting the frames and processing them

We have to cut in pieces the video getting the frames and add a centroid in the center of the ball that is going to be our coordinates in the frame, comparing this values with the ones we can provide in a modeled sample (x,y)

For obtein this values I have been using cv2, a powerful library write in Python taht allow us to modify the frame and get exactly want we want. The steps we are going to take are the following, trying to get the best perperstive and exact pixel in the frame to have the best prediction possible with our model. After a lot of tries the best values I was able to get the expected results were:

  • Frame resized (120x80 pixels).
  • RGB Color to HSV.
  • Mask in the object by differences in colors thanks to the HSV filter.
  • To gray scale.
  • To binary scale.
  • Erosion(3,3), makes the borders softer.
  • Dilation(5,5), mark the borders diffrences.
  • Add the centroid in the object.
  • Export the values and get the original frame with the coordenates write above the ball.

We realized that we have to change the color of the ball and the background for getting better results.

Here you can see the proccess by steps:

Cap0
Cap1
Cap2