查找相机到已知大小物体的距离 [英] Finding distance from camera to object of known size

查看:189
本文介绍了查找相机到已知大小物体的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用opencv编写一个程序,以计算从摄像头到一英寸白球的距离.我觉得这应该很容易,但是无论出于什么原因,我都将空白.感谢您的提前帮助.

I am trying to write a program using opencv to calculate the distance from a webcam to a one inch white sphere. I feel like this should be pretty easy, but for whatever reason I'm drawing a blank. Thanks for the help ahead of time.

推荐答案

您可以使用三角形相似度来校准相机角度并找到距离.
您知道球的大小:D单位(例如,厘米).将其放在相机前面的已知距离Z中,例如1米= 100厘米,并以像素为单位测量其视在宽度.将此宽度称为d.
摄像机f的焦距(每个摄像机的焦距稍有不同)为f=d*Z/D.

You can use triangle similarity to calibrate the camera angle and find the distance.
You know your ball's size: D units (e.g. cm). Place it at a known distance Z, say 1 meter = 100cm, in front of the camera and measure its apparent width in pixels. Call this width d.
The focal length of the camera f (which is slightly different from camera to camera) is then f=d*Z/D.

当您再次用此摄像机看到该球,并且它的视在宽度为d'像素时,通过三角形相似性,您会知道f/d'=Z'/D,因此:Z'=D*f/d'其中Z'是球到当前球的距离相机.

When you see this ball again with this camera, and its apparent width is d' pixels, then by triangle similarity, you know that f/d'=Z'/D and thus: Z'=D*f/d' where Z' is the ball's current distance from the camera.

这篇关于查找相机到已知大小物体的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆