OpenCV discovers tennis court lines behind the net

I am trying to implement a tennis court detector using video recorded from a telephone. I took it from the far corner of the tennis court.

The original image is as follows.

Source image

Using the OpenCV Canny Edge Detection and the Hough Lines transform, I can detect lines in my own half, but not the ones behind the network. How can I improve this process and get undetected court lines?

The processed image is as follows.

Processed Image


Updated on 2016-08-25

Thanks guys. I understand that it makes sense to output court lines by setting the detected lines to model lines. I am not going to do a combinatorial search to find the best lines suitable for the models. So I tried to separate the horizontal / vertical lines in order to reduce the computational complexity. I tried RANSAC to find vanishing points (VP) that connect two different groups of strings, but failed due to a detection error (?).

The scatter plot of the line parameters in polar coordinates is shown below. Basically, classify points into two groups: top points that form a horizontal line; lower left dots, which also form a line with a deep slope. Is there any way to do this? Thanks

Polar coordinate

+6
source share
3 answers

You do not need to detect lines behind the network. You know that the earth is a flat plane, you know that the dimensions of each side of the yard are the same - so you only need to find nearby lines, and you can calculate where the missing lines are.

In fact, you really only need to detect one angle if you know the characteristics of the camera + lens.

+3
source

In addition to Martin's comments, you can try using some kind of image blur before triggering your edge / line detection. With some tweaking, you must remove the network signal and maintain the ship lines.

Another approach would be to reduce the thick lines to one pixel by scanning the image from left to right (for example) to detect transitions from red / green to white and back to red / green again. When this happens, you can appreciate that the middle of these two transitions is the middle of the court line. This would give you data that you could feed directly into your Hough transform. This, of course, requires you to classify individual pixels as courts or lines that you don't seem to be doing right now. This process can also be performed from top to bottom to create a second set of medium calculations.

+2
source

To blur try a double-sided filter

Image input example:

input image

cv2.bilateralFilter(img_gray,30,25,75) 

image output:

motion blur without loss of court information

+1
source

All Articles