def validate_clockwise_points(points):
"""
Validates that the points that the 4 points that dlimite a polygon are in clockwise order.
"""
# if len(points) != 8:
# raise Exception("Points list not valid." + str(len(points)))
# point = [
# [int(points[0]) , int(points[1])],
# [int(points[2]) , int(points[3])],
# [int(points[4]) , int(points[5])],
# [int(points[6]) , int(points[7])]
# ]
# edge = [
# ( point[1][0] - point[0][0])*( point[1][1] + point[0][1]),
# ( point[2][0] - point[1][0])*( point[2][1] + point[1][1]),
# ( point[3][0] - point[2][0])*( point[3][1] + point[2][1]),
# ( point[0][0] - point[3][0])*( point[0][1] + point[3][1])
# ]
# summatory = edge[0] + edge[1] + edge[2] + edge[3];
# if summatory>0:
# raise Exception("Points are not clockwise. The coordinates of bounding quadrilaterals have to be given in clockwise order. Regarding the correct interpretation of 'clockwise' remember that the image coordinate system used is the standard one, with the image origin at the upper left, the X axis extending to the right and Y axis extending downwards.")
pts = [(points[j], points[j+1]) for j in range(0,len(points),2)]
try:
pdet = Polygon(pts)
except:
assert(0), ('not a valid polygon', pts)
# The polygon should be valid.
if not pdet.is_valid:
assert(0), ('polygon has intersection sides', pts)
pRing = LinearRing(pts)
if pRing.is_ccw:
assert(0), ("Points are not clockwise. The coordinates of bounding quadrilaterals have to be given in clockwise order. Regarding the correct interpretation of 'clockwise' remember that the image coordinate system used is the standard one, with the image origin at the upper left, the X axis extending to the right and Y axis extending downwards.")
The commented code and the working code has opposite result for a same input.
I think the issue is shapely do the computation on Descartian coordinate system, and we use image pixel coordinate system which have opposite result?
Maybe the judgement should be simplely changed to if not pRing.is_ccw:
https://github.com/aim-uofa/AdelaiDet/blob/5e19cb172b8363820b409ed1a2754fb19ad3acb8/adet/evaluation/rrc_evaluation_funcs.py#L298
The commented code and the working code has opposite result for a same input.
I think the issue is shapely do the computation on Descartian coordinate system, and we use image pixel coordinate system which have opposite result?
Maybe the judgement should be simplely changed to
if not pRing.is_ccw: