Closed igo312 closed 3 years ago
The angle of box is in the range of [-90, 0) or (-90, 0], and therefore the t r b l points are guaranteed to be distributed in different quadrants. For example, bottom point is in the fourth quadrant.
I get what you mean. the four vector are guanranteed to be in four quadrants
But the another problem is the ouput order. for example in some images the channel [0:2] of wh
is the top left vector, but in other images is the bottom left vector, I think it will confuse the model. Cause the order is important therefore the kernel will learn better.
Here's my experiment script and result, I also upload a picture hope for explaining better.
cv2.boxPoints(((200,300),(30,70),10))
# output
#array([[179.1502 , 331.86353],
# [191.30557, 262.927 ],
# [220.8498 , 268.13647],
# [208.69443, 337.073 ]])
cv2.boxPoints(((200,300),(30,70),-10))
# ouput
# array([[191.30557, 337.073 ],
# [179.1502 , 268.13647],
# [208.69443, 262.927 ],
# [220.8498 , 331.86353]])
the vetcor color means the right order, and the number is the result of this script will return.
I used top, right, bottom, left
vectors. The top vector has an acute angle with the y-axis counterclockwise. The angle only ranges from [-90, 0) or (-90, 0]. Your examples are not in this range. However, the order 1,2,3,4
is right, corresponding to bl, tl, tr, br
. Then top
vector is still in the second quadrant.
I get what you mean. and use function reorder_pts
should work. but here's some problem.
reorder_pts
is whether theta is in a list which only have three elements rather than a range.'4.5.1'
, and the theta from cv2.minAreaRect
is positive. here's my experiment
a = cv2.boxPoints(((200,300),(30,70),10))
cv2.minAreaRect(a.astype(np.int))
>>> ((199.49998474121094, 299.4999694824219), (29.59918975830078, 70.97808837890625), 9.865806579589844)
a = cv2.boxPoints(((200,300),(30,70),-10)) cv2.minAreaRect(a.astype(np.int))
((199.5, 299.5), (70.97808837890625, 29.59918975830078), 80.13418579101562)
So I still think there still exists problem about the order...
Sorry, I don't know what you want by running this script. and here's my result. the angle still is positive. anyway thanks for your response. But really want to get it done, so may I have your wechat or any IM counter?
print(pt_new)
>>>[[401.76877 607. ]
[516.1002 35.47373 ]
[193.91083 0. ]
[ 79.579384 569.5174 ]]
print(self.down_ratio)
>>> 4
print(cv2.minAreaRect(pt_new/self.down_ratio))
>>> ((74.45994567871094, 75.6238784790039), (80.82061767578125, 152.323974609375), 11.312458038330078)
pts
array([[401.76877 , 607. ],
[516.1002 , 35.47373 ],
[193.91083 , 0. ],
[ 79.579384, 569.5174 ]], dtype=float32)
cv2.minAreaRect(pts/self.down_ratio)
((74.45994567871094, 75.62389373779297), (152.323974609375, 80.82061767578125), -78.68754577636719)
opencv-python 4.3.0.36 pypi_0 pypi
For my cases, the angle will be restricted in a[-90,0), which is different than yours. But it should be good if the angle is restricted in one quadrant. The name of the vectors does not matter at all, they just different types.
yeah
Finally I get what you mean, regard the center of object is the origin of the Cartesian coordinates. the four vetcor will be distributed in four quadrant in order even the cv2.boxPoints
doesn't return points in a fix order.
Anyway, thanks for your patience, looking forward to your next great work!
It's good work, but here's my question.
you use
cv2.boxPoints
inbase.py::generate_ground_truth
to make four vector.And it seems you think the first point of return values is bottom left point. But in this problem, it proves that the first point is the lowest point instead of bottom left point.And I also have a experiment and the result is same to the above.
So what do you think? Right now I have no idea that why the network work, but it's not appropriate to set four points directlly.