Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question #13

Closed
suqian1988 opened this issue Feb 12, 2022 · 3 comments
Closed

question #13

suqian1988 opened this issue Feb 12, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@suqian1988
Copy link

Can the tennis-tracking mark the ball bounce position in the video?

thank you very much.
Mike

@shukkkur shukkkur self-assigned this Feb 14, 2022
@shukkkur shukkkur added the enhancement New feature or request label Feb 14, 2022
@shukkkur
Copy link
Collaborator

shukkkur commented Feb 14, 2022

@suqian1988 Hi Mike, thanks for opening the issue!
Yes, it sure can.
Here, if you pass --bounce=1, it should mark the bounces in blue and display them, like in the following image (unless the model failed to predict bounces 😅)

image

If you want all the bounces to be marked on the court, then 👇

predcted = clf.predict(X)
idx = list(np.where(predcted == 1)[0])
idx = np.array(idx) - 10

the list idx stores the frame numbers where the ball touches the court. So, change this
while True:
ret, frame = video.read()
if ret:
# if coords[i] is not None:
if i in idx:
center_coordinates = int(xy[i][0]), int(xy[i][1])
radius = 3
color = (255, 0, 0)
thickness = -1
cv2.circle(frame, center_coordinates, 10, color, thickness)
i += 1
output_video.write(frame)
else:
break

with this

  while True:
    ret, frame = video.read()
    if ret:
      # if coords[i] is not None:
      for loc in idx:
        center_coordinates = int(xy[loc][0]), int(xy[loc][1])
        radius = 3
        color = (255, 0, 0)
        thickness = -1
        cv2.circle(frame, center_coordinates, 10, color, thickness)
      i += 1
      output_video.write(frame)
    else:
      break

Didn't run the code myself, but should work.
Feel free to reopen the issue, anytime!
😄

@suqian1988
Copy link
Author

suqian1988 commented Feb 14, 2022 via email

@shukkkur
Copy link
Collaborator

@suqian1988 No, the code provided will mark the bounces only on the real court itself.
As for for marking on the black court (mini-map), it is a bit more complex. We will need the inverse matrix and will then apply perspective transform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants