在他们的文档中:
http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#getrectsubpix
公式是:
dst(x, y) = src(x + center.x - ( dst.cols -1)*0.5, y + center.y - ( dst.rows -1)*0.5)
但是为什么我们需要使用(dst.cols-1)?
我认为我们应该直接使用dst.cols和dst.rows。
最佳答案
这是因为位置是从0开始的。
考虑当dest_cols == 9
会发生什么。使用公式,其中心在4处正确。使用您的版本,其中心位于4.5,不正确。
现在考虑当dest_cols == 10
会发生什么。使用公式,其中心位于4.5处是正确的。使用您的版本,其中心位于5,不正确。
关于opencv - OpenCV getRectSubPix:为什么其公式使用(dst.cols-1)* 0.5?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29104239/