如何以像素为单位从图像中的对象大小(如英寸厘米等)来衡量现实世界中的对象大小? [英] How to measure object size in real world in terms of measurement like inches centimeters etc from object size in the image in pixels?

查看:112
本文介绍了如何以像素为单位从图像中的对象大小(如英寸厘米等)来衡量现实世界中的对象大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从包含对象的图像中根据pixel计算了对象大小.我想测量现实世界中的物体大小.有什么方法可以找出测量实际尺寸的倍数?我目前正在使用python进行实施.

解决方案

通常,您将使用照相机获得图像,该照相机将3D场景通过镜头投影到2D传感器上.下图表示垂直(高度)投影(我假设是直线透镜):

您说您感兴趣的对象的高度(以图像像素为150像素):

您说图像尺寸的总高度为800像素,假设这是传感器分辨率:

您有兴趣在距离摄像机 D 的物体 H_ {obj} 的公制中查找其实际高度.

弧度表示角度,我们可以建立以下关系:

其中 f 是镜头的焦距.

隔离条款并代替我们达成

但是您已经以像素为单位表示了h_ {obj},并且希望以公制表示H_ {obj}.因此,让我们先从像素移动到毫米.

让我们假设您不知道传感器的高度,因此我们暂时将其保留为变量.重新排列,将焦距表示为毫米(mm)并代入上一个方程式:

注意该词:

\ alpha代表摄像机的垂直视场(因为我们使用传感器的高度),这是通常为摄像机&设置的参数.镜头计算.

通常以度为单位给定,因此我们将其转换为弧度.

  • 如果您实际上知道镜头的焦距和传感器的尺寸,只需直接计算视场即可.这使我们有了以下等式:

视野"是您缺少的参数,以便能够完成计算.为了完成该示例,我们假设其为90º:

您现在用来表示距离 D 的单位制将定义h_ {obj}的表示单位.


另一种方法是,在给定视场的情况下,并假设使用直线透镜,则可以在距相机一定的距离处计算像素高度和像素宽度.

距离D处的垂直分辨率


有关视野的更多信息:

I have calculated object size in terms of pixel from the image containing object. I want to measure object size in real world. Is there any way to find out multiplying factor to measure actual size ? I'm currently using python for implementation.

解决方案

Typically you will have obtained your image with a camera which projects the 3 dimensional scene onto a 2 dimensional sensor by means of a lens. The vertical (height) projection is represented in the following diagram ( I am assuming a rectilinear lens):

You say the height of your object of interest in pixels of your image as 150 pixels:

You say the image size has a total height of 800 pixels, assuming this is the sensor resolution:

You are interested in finding the real height in metric system of the object H_{obj} that finds itself at distance D from the camera.

Expressing the angles in radians we can establish the following relationships:

where f is the focal length of the lens.

isolating terms and substituting we reach

but you have expressed h_{obj} in pixels and you want H_{obj} expressed in the metric system. So, lets first move from pixels to millimeters.

Lets assume you don't know the sensor height, so we keep it as the variable for the moment. Rearranging, expressing focal length as millimeters (mm) and substituting into the previous equation we have:

notice the term :

\alpha represents the Vertical Field of View (since we use the sensor height) of the camera, this is a parameter that is typically given for camera & lens calculations.

Normally its given in degrees, so we just convert it to radians.

  • If you actually know the focal length of your lens and the size of your sensor, just calculate the Field of View directly. This leaves us with the following equation:

The Field of View is the parameter you are missing to be able to complete your calculation. To complete the example let's assume it is 90º:

The system of units you use now to express your distance D will define the units with which the h_{obj} will be expressed in.


Another approach is, given a Field of View, and assuming a rectilinear lens, you can calculate pixel height and pixel width at a defined distance from the camera.

Vertical resolution at distance D


For more information on Field of view:

这篇关于如何以像素为单位从图像中的对象大小(如英寸厘米等)来衡量现实世界中的对象大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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