Ask Your Question

o.k's profile - activity

2020-07-29 10:27:34 -0500 commented answer Finding corner points for perspective transform without clear landmarks.

This is awesome thank you! I think this goes in the right direction but my results aren't perfect. What do you think abo

2020-07-29 10:20:53 -0500 marked best answer Finding corner points for perspective transform without clear landmarks.

Hi, I posted this question two days ago, which leaded me to a new problem to solve.

I need to define 4 trapezoid corner points on an image (golf lawn) without any distinct landmarks on it. Except the balls and the flag. All visible balls and the flag must be in the trapezoid.

@kbarni pointed me to some possible solutions but I'm not sure what to do now.

Also I'm pretty bad at math and I have a hard time understanding the formulas explaining computer vision concepts.

Here are my thoughts about how I could eventually get to the corner points but I have no idea how to do it or if it's even possible.


Input

This is the image of interest:

image description


Goal

The goal is to find the corners with the image as is (no extra markers placed in real life).

These are approximately the corners I'm looking for, here I've set the corners by hand which of course isn't 100% accurate.

The corners will be used with getPerspectiveTransform and warpPerspective to get a top down view.

I don't necessarily need the extra padding between the outer most balls and the lines.

image description


Solution?

I do know some variables from the image. I do some balls detection using YOLO and mark them. The model does a decent job at the moment and will get better so that the balls will be market pretty accurately (I hope).

image description

With the detection I can get/know:

  • The balls width/height in pixels/mm
  • The balls centroids

At the moment I don't detect the flag but I will soon.

In real life a golf ball has a diameter of 42.67mm and the hole 107.95mm


What I was thinking of is that I could get a trapezoid from the nearest (biggest) ball bottom corners to the furthest (smallest) ball bottom corners (or something similar) and somehow transform and apply it to the group and align it correctly to get my goal corner points?

Is this in any way possible with the given variables and what do you think about this idea?

Please tell me if you guys need more information.

Help would be greatly appreciated!

Edit/Results

Here are my results after applying @kbarni s answer below and they are pretty awesome imo, even if there is still some work pending to get this done perfectly.

I changed the provided formula a little bit:

(0, C.y),(W,C.y),(W/2+R*W,F.y),(W/2-R*W,F.y)

Where C.y is taken from a bottom corner and F.y from a top corner to have all balls inside the trapezoid.

image description

And here is the top down view result at the moment.

image description

2020-07-29 10:20:51 -0500 received badge  Supporter (source)
2020-07-29 10:20:39 -0500 commented answer Finding corner points for perspective transform without clear landmarks.

This is awesome thank you! I think this goes in the right direction but my results aren't perfect. What do you think abo

2020-07-29 10:16:52 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 10:16:06 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 06:47:55 -0500 commented answer Finding corner points for perspective transform without clear landmarks.

Ok I'll do some trials and give feedback. Thx again

2020-07-29 06:12:51 -0500 commented question Finding corner points for perspective transform without clear landmarks.

Hi @kbarni, thx for responding (again). Yes I wasn't sure if YOLO is the right approach. I tried HoughCircles with Canny

2020-07-29 06:12:31 -0500 commented question Finding corner points for perspective transform without clear landmarks.

Hi @kbarni, thx for responding (again). Yes I wasn't sure if YOLO is the right approach. I tried HoughCircles with Canny

2020-07-29 05:43:33 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 05:32:17 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 05:27:45 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 05:13:25 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 05:09:52 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 05:09:35 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 05:06:02 -0500 edited question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-29 04:56:33 -0500 asked a question Finding corner points for perspective transform without clear landmarks.

Finding corner points for perspective transform without clear landmarks. Hi, I posted this question two days ago, which

2020-07-27 09:45:54 -0500 commented answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

With colored points you mean for example 4 physical red balls forming a rectangle lying on the lawn for each image (perf

2020-07-27 09:45:21 -0500 commented answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

With colored points you mean for example 4 physical red balls forming a rectangle lying on the lawn for each image (perf

2020-07-27 09:41:32 -0500 marked best answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Hi, I'm following some tutorials to change an image of a golf green with balls to bird-eye view to measure distances in a later step.

Now when I apply the transformation to an image with some text on paper it seems to work, but when applied to the outdoor image the results are not as expected.

Here an example with the outdoor image coords and dimensions:

# targeted rectangle on original image which needs to be transformed
tl = [689, 892]
tr = [2518, 892]
br = [2518, 2071]
bl = [689, 2071]

corner_points_array = np.float32([tl,tr,br,bl])

# original image dimensions
width = 4128
height = 2322

# Create an array with the parameters (the dimensions) required to build the matrix
imgTl = [0,0]
imgTr = [width,0]
imgBr = [width,height]
imgBl = [0,height]
img_params = np.float32([imgTl,imgTr,imgBr,imgBl])

# Compute and return the transformation matrix
matrix = cv2.getPerspectiveTransform(corner_points_array,img_params)
img_transformed = cv2.warpPerspective(image,matrix,(width,height))

And here are my results for the golf image:

 input

image description

output

image description

As you can see I don't get a nice bird-eye view.


This is the result I get with text and paper using the same script just with different coords and dimensions:

 Input

image description

output

image description

So what am I doing wrong with the first golf example? Any help would be greatly appreciated.

2020-07-27 09:41:32 -0500 received badge  Scholar (source)
2020-07-27 09:41:28 -0500 commented answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

With colored points you mean for example 4 physical red balls forming a rectangle lying on the lawn for each image (perf

2020-07-27 09:19:39 -0500 commented answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Hey, thx for your answer, I think I understand. But how do I know where to put my trapezoid corner points in the golf ex

2020-07-27 09:19:12 -0500 commented answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Hey, thx for your answer, I think I understand. But how do I know where to put my trapezoid points in the golf example i

2020-07-27 09:19:05 -0500 commented answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Hey, thx for your answer, I think I understand. But how do I where to put my trapezoid points in the golf example in ord

2020-07-27 09:18:35 -0500 commented answer Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Hey, thx for your answer, I think I understand. But how do I know how to define my trapezoid points in the golf example

2020-07-27 07:21:02 -0500 edited question Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python). Hi, I'm following some tutorials to change

2020-07-27 07:20:58 -0500 received badge  Editor (source)
2020-07-27 07:20:58 -0500 edited question Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Apply getPerspectiveTransform and warpPerspective for bird-eye view. Hi, I'm following some tutorials to change an image

2020-07-27 07:06:31 -0500 asked a question Apply getPerspectiveTransform and warpPerspective for bird-eye view (Python).

Apply getPerspectiveTransform and warpPerspective for bird-eye view. Hi, I'm following some tutorials to change an image

2020-07-27 07:06:31 -0500 asked a question Apply getPerspectiveTransform and warpPerspective for bird-eye view.

Apply getPerspectiveTransform and warpPerspective for bird-eye view. Hi, I'm following some tutorials to change an image