图像中按距离进行对象插值

发布于 2024-09-15 05:52:44 字数 382 浏览 7 评论 0原文

我正在计算图像中的对象。我希望执行线性插值,其中我知道对象在近处和远处的像素大小以及这两个对象在图像中的位置。图像底部的图像较大,因为它们靠近拍摄它们的相机。

要分析的图像与此问题相同......

链接文本 插值仅适用于一个平面,从上到下,因此有关如何正确执行插值的想法会很好。这是一篇硕士学位论文,我已经完成了“困难”部分——图像分类、数据收集,但是我刚刚在 Java(当前使用)和 R(现在仅用于统计)之间遇到了心理障碍,任何帮助将不胜感激!

I'm counting objects in an image. I wish to perform a linear interpolation where I know the pixel sizes of my objects at near and far perspectives and the positions of these two objects in the image. The images at the bottom of the image are larger as they are near the camera which took them.

The image to be analysed is the same from this question here...
link text

I realise that linear interpolation will only work on one plane, here from top to bottom, so ideas on how to do it properly would be good. It is for a masters dissertation, I've done the 'hard' bits - image classification, data collection, however I've just hit a mental brick wall, between Java (currently using) and R (now just for stats), any help would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尴尬癌患者 2024-09-22 05:52:53

单应性是一种数学方法,它将距相机的物体距离转换为尺寸变化,该尺寸变化由透视投影。

基本上,物体在相机图像上出现的尺寸与物体的真实尺寸除以物体与相机的距离成正比。

假设有两个对象 A 和 B,它们具有相同的真实大小。 A 位于距离 DA 处,B 位于距离 DB 处。它们在相机图像中显示的大小为 HA 和 HB

对于物体 C,与 A 和 B 具有相同的真实世界大小,位于距离 (1-α)DA + (α)DB 处,其大小相机图像上的值由下式给出:

Homography is the mathematical method that translates between object distances from the camera into the size variation that results from perspective projection.

Basically, the size of object as it appears on a camera image is proportional to the real-world size of the object divided by the object's distance from the camera.

Let's say there are two objects, A and B, that have the same real-world size. A is at distance DA and B is at distance DB. Their sizes, as they appear in the camera image, are HA and HB.

For an object C, same real-world size as A and B, that is located at distance (1-α)DA + (α)DB, its size on the camera image is given by:

仲春光 2024-09-22 05:52:49

所以我会使用 3D 投影方程并向后计算它们以找到场景中某个对象的 x、y、z。因此,根据物体的大小、相机的焦距,您可以计算出帧中物体的 x、y、z。

我会对相机做出一些假设(没有旋转,没有平移,相机位于 z 轴的 0, 0, 0 位置)。

image.x = model.x * camera.focalLength / model.z
image.y = model.y * camera.focalLength / model.z

将它们翻转过来,您会得到:

model.x = image.x * model.z / camera.focalLength;
model.y = image.y * model.z / camera.focalLength;

这假设您知道您认为物体距相机所在的点(即 model.z)的距离。同样,如果你想计算物体与相机的距离,你可以这样计算 model.z:

model.z = model.x * camera.focalLength / image.x
model.z = model.y * camera.focalLength / image.y

我想技巧是弄清楚在这种情况下你应该使用 model.x 和 model.y 。利用对象的宽度或对象的高度,您可以得出对象的恒定宽度与场景中对象随距离变化的宽度之间的关系。

model.z = model.width * camera.focalLength / image.width;
model.z = model.height * camera.focalLength / image.height;

几天来我一直在等待这个答案,所以我检查了我的事实。但这与另一篇文章大致一致。

So I'd use 3d projection equation and work them backwards to find the x,y,z of some object in your scene. So given the size of your object, focal length of your camera, you can calculate the x,y,z of the objet in the frame.

I'd make some assumptions about the camera (no rotation, no translation the camera is sitting at 0, 0, 0 down the z axis).

image.x = model.x * camera.focalLength / model.z
image.y = model.y * camera.focalLength / model.z

Flipping them around you get:

model.x = image.x * model.z / camera.focalLength;
model.y = image.y * model.z / camera.focalLength;

This assumes you know the distance to the point you believe the object rests from the camera (i.e. model.z). Similarly if you want to calculate the distance of the object from the camera you can calculate the model.z this way:

model.z = model.x * camera.focalLength / image.x
model.z = model.y * camera.focalLength / image.y

Trick I suppose is figuring out what you should use for model.x, and model.y in this case. Taking either the width of your object or the height of your object you can come up with a relationship between constant width in your object and the width of your object in the scene as it changes in distance.

model.z = model.width * camera.focalLength / image.width;
model.z = model.height * camera.focalLength / image.height;

Been sitting on that answer for a few days so I check my facts. But that roughly agrees with the other post.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文