ef rotatePoint(xc, yc, xp, yp, theta):
xoff = xp - xc
yoff = yp - yc
cosTheta = math.cos(theta)
sinTheta = math.sin(theta)
pResx = cosTheta * xoff + sinTheta * yoff
pResy = - sinTheta * xoff + cosTheta * yoff
return xc + pResx, yc + pResy
def addRotatedShape(cx, cy, w, h, angle):
p0x, p0y = rotatePoint(cx, cy, cx - w / 2, cy - h / 2, -angle)
p1x, p1y = rotatePoint(cx, cy, cx + w / 2, cy - h / 2, -angle)
p2x, p2y = rotatePoint(cx, cy, cx + w / 2, cy + h / 2, -angle)
p3x, p3y = rotatePoint(cx, cy, cx - w / 2, cy + h / 2, -angle)
return p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y
样例数据:
转换前:
2 284.755840 55.945635 17.589079 125.675577 -5.620411
转换后:
316.4876871422387, 1.0000121940895426, 330.3529509009749, 11.82268104095521, 253.02399285776124, 110.89125780591047, 239.15872909902504, 100.06858895904477
可视化:
旋转框标注工具:
https://github.com/zexihan/labelImg-kitti