考虑到 OpenCV 在使用 WarpAffine 旋转时会向图像添加黑色边框,如何旋转坐标?

How to rotate coordinates taking into account that OpenCV adds black borders to the image when rotating with WarpAffine?

我有这张图片:

我有白色圆圈中心的坐标。我还有这张图片:

,它们是同一幅图像,但第二幅图像使用 OpenCV 的 WarpAffine 旋转了 4°。我想做的是计算4°图像中白色圆圈的中心坐标,考虑到OpenCV的WarpAffine在旋转时会给图像添加黑色边框。

您可以在 WarpAffine 的变换矩阵上乘以圆的坐标:(x* y* 1) = TrMat * (x y 1)T

理论is here. In Python: numpy.dot