gpt4 book ai didi

opencv - OpenCV getRectSubPix:为什么其公式使用(dst.cols-1)* 0.5?

转载 作者:行者123 更新时间:2023-12-02 17:48:26 24 4
gpt4 key购买 nike

在他们的文档中:
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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com