图像中按距离进行对象插值
我正在计算图像中的对象。我希望执行线性插值,其中我知道对象在近处和远处的像素大小以及这两个对象在图像中的位置。图像底部的图像较大,因为它们靠近拍摄它们的相机。
要分析的图像与此问题相同......
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
单应性是一种数学方法,它将距相机的物体距离转换为尺寸变化,该尺寸变化由透视投影。
基本上,物体在相机图像上出现的尺寸与物体的真实尺寸除以物体与相机的距离成正比。
假设有两个对象 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:
所以我会使用 3D 投影方程并向后计算它们以找到场景中某个对象的 x、y、z。因此,根据物体的大小、相机的焦距,您可以计算出帧中物体的 x、y、z。
我会对相机做出一些假设(没有旋转,没有平移,相机位于 z 轴的 0, 0, 0 位置)。
将它们翻转过来,您会得到:
这假设您知道您认为物体距相机所在的点(即 model.z)的距离。同样,如果你想计算物体与相机的距离,你可以这样计算 model.z:
我想技巧是弄清楚在这种情况下你应该使用 model.x 和 model.y 。利用对象的宽度或对象的高度,您可以得出对象的恒定宽度与场景中对象随距离变化的宽度之间的关系。
几天来我一直在等待这个答案,所以我检查了我的事实。但这与另一篇文章大致一致。
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).
Flipping them around you get:
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:
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.
Been sitting on that answer for a few days so I check my facts. But that roughly agrees with the other post.