# Estimate the location of an object in a field using computer vision and math

I'm trying to see how to detect the location of a soccer ball in the field using the live camera. What are some ways to achieve this? At this point I'm more interested in ideas and thoughts and not really code.

1- Assuming we have a fixed camera with a wide shot. How to find the ball location on the actuall field? It's probably using a computer vision approach.

2- A camera is zooming into the ball. But we know the location of the camera and maybe it's turning angle. Can we estimate the ball location on the field using this info? Or maybe we need additional info? Can we do it with two cameras as reference points? Maybe some math or triangulation sort of approaches would help here.

Any thoughts would be helpful.

## 1 Answer

Your problem is focused on the object detection perspective. For a intro into the topic with some code you could look into this - https://medium.com/analytics-vidhya/detecting-objects-on-ip-camera-video-with-tensorflow-and-opencv-e2c25297a75a.

General object detection is quite easy for the second picture but for the first it would be a bit difficult. You could use dlib and CNN networks such as YOLO and RCNN (family of models).

Yes you could do it with two cameras. The configuration depends on you whether you use selected area for both cameras or both cameras cover the entire field.

https://www.geeksforgeeks.org/detect-an-object-with-opencv-python/ - The code here detects stop signs. You could find a dataset which deals with footballs/sports and do the exact same.

This link provides your objective for close range (zoomed in) photos - https://towardsdatascience.com/yolov2-to-detect-your-own-objects-soccer-ball-using-darkflow-a4f98d5ce5bf

• Thanks. Useful codes. At this point I'm more interested in ideas and thoughts and not really code. – Tina J Oct 31 '20 at 14:11