OpenCV透视变换正确的目标宽度和高度?
我目前正在使用 OpenCV 及其透视变换函数。我想找到一种方法来根据我拥有的数据(源图像)准确确定目标矩形。 我已经找到了这个线程:https://stackoverflow。 com/questions/7199116/perspective-transform-how-to-find-a-target-width-and-height 它指出,不可能根据源中包含的数据正确确定正确的纵横比,但至少有一个好的算法来获得良好的估计吗?
I am currently working with OpenCV and its perspective transformation functions. I'd like to find a way to accurately determine the target rectangle based on the data (the source image) I have.
I already found this thread: https://stackoverflow.com/questions/7199116/perspective-transform-how-to-find-a-target-width-and-height
It states, that it is not possible to determine the correct aspect ratio correctly on the data contained in the source, but is there at least a good algorithm to get a good estimate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,没有办法仅通过图像来做到这一点。想象一下,您正在拍摄一张放在桌子上的 A4 纸的照片,只是您几乎水平地看着它。如果您使用图像中的长宽比,您最终会得到一个非常长且细的矩形。
但是,如果您知道相机相对于目标的位姿(即旋转矩阵)和相机内在参数,那么您就可以获得纵横比。
看看这篇论文(它实际上是真的很有趣,虽然英语不是最好的):方程(20)是关键之一。另外,请查看这篇博文,其中某人实施了该方法。
如果您不知道相机的方向,那么最好的选择是输入某种至少大约的纵横比。如果您有关于矩形的任何其他信息,请使用它(例如,如果我总是拍摄 A[0,1,2,...] 纸片的照片,这些纸片具有已知的固定纵横比)。
祝你好运!
No, there isn't a way to do it from just the image alone. Imagine you were taking a picture of an A4 sheet of paper resting on a table, only you were looking at it near-on horizontal. If you used the aspect ratio from the image, you'd end up with a really long, thin rectangle.
However, if you know the pose of the camera relative to the target (ie rotation matrix) and the camera intrinsic parameters, then you can get the aspect ratio.
Have a look at this paper (it's actually really interesting, though the English isn't the best): equation (20) is the key one. Also, look at this blog post where someone's implemented the approach.
If you don't know the orientation of the camera then the best bet is to put in some sort of aspect ratio that is at least ballpark. If you have any other info about the rectangle, use that (for example if I was always taking photos of A[0,1,2,...] pieces of paper, these have a known fixed aspect ratio).
good luck!