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

Positive width and height and corners2rotatedbbox(corners) function #310

Open
MteaHubHug opened this issue Sep 15, 2021 · 1 comment
Open

Comments

@MteaHubHug
Copy link

In the function :

def _corners2rotatedbbox(corners):
centre = np.mean(np.array(corners), 0)
theta = calc_bearing(corners[0], corners[1])
rotation = np.array([[np.cos(theta), -np.sin(theta)],
[np.sin(theta), np.cos(theta)]])
out_points = np.matmul(corners - centre, rotation) + centre
x, y = list(out_points[0,:])
w, h = list(out_points[2, :] - out_points[0, :])
return [x, y, w, h, theta]

width and height are computed like this : w, h = list(out_points[2, :] - out_points[0, :])

It is ok to just take absolute value because width and height has to be positive.
(see sketch1)
image

So, you can just change it to :
w, h = list(out_points[2, :] - out_points[0, :])
w= math.fabs(w)
h=math.fabs(h)
return [x, y, w, h, theta]

Still, I think this:
w, h = list(out_points[2, :] - out_points[0, :])
is not correct way to compute width and height (see my schetch2).
image

I think that is ok just when box is not roatated. In rotated case, it has to be :
w= math.distance(point1,point2)
h=math.distance(point2,point3)

Pls, tell me what do you think about this?
BR

@ghost
Copy link

ghost commented Sep 23, 2021

Thanks, we will look into this and let you know.

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

No branches or pull requests

1 participant