如何在WPF,vb.net中测量两个对象(图像)之间的距离? [英] how to measure the distance between two objects (image) in WPF, vb.net?

查看:110
本文介绍了如何在WPF,vb.net中测量两个对象(图像)之间的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。



我想知道,无论如何测量两个物体之间的距离(设置为图像文件)?, 2个物体的像素距离将是转换为米。



提前致谢。 :)



我正在使用vb.net,WPF

Hi.

I would like to know, is there anyway how to measure the distance between two objects (set as an image file)?, the pixel distance of the 2 objects will be converted to meters.

Thanks in advance. :)

I am using vb.net, WPF

推荐答案

获取鞋面左控件的一点你可以使用 Control.Location [ ^ ]属性。



现在,当你从控件中得到这两点时,你只需要搞清楚每个的中心或边缘(取决于你的计算应该做什么)然后做SQRT(X 2 + Y 2 )并乘以像素到米您有比率。





*如果您打算根据纬度和经度计算两个地理位置之间的距离,请检查< a href =http://www.dreamincode.net/forums/topic/97817-calculate-distance-between-lat-and-long/>关于如何校准的以下Q& A拉特和长期之间的距离 [ ^ ]



干杯,

Edo
To get the upper left point of a control you can use the Control.Location[^] property.

Now, when you get those two points out of your controls, you just need to figure out the center or edge of each one (depending on what your calculation is supposed to do) and then do SQRT(X2 + Y2) and multiply by the pixel to meter ratio you have.


* If you meant to calculate distance between two geo positions based on Latitude and Longitude, check the following Q&A on How to calculate Distance Between Lat And Long[^]

Cheers,
Edo


不是真的,不是 - 不适用于普通图像。



请记住,图像是三维场景的二维表示,所以两个通过第三维度,相隔像素的项目在现实世界中可以相距几英里。为了解决您的问题,即使图像是2D场景(桌子上的一堆物体,例如从上方直接看到),除非图像是包含比例信息(距离桌子和一些参考点),不知道像素和仪表之间的关系。如果您知道其中一个对象(一个参考对象)的大小,那么如果您可以自动识别它,那么您可以这样做,但这是一堆工作都在它自己。



对于随机挑选的通用图像?没机会。
Not really, no - not for "normal" images.

Remember, an image is a two dimensional representation of a three dimensional scene, so two "items" a pixel apart could be several miles apart in the real world via the third dimension. To add to your problems, even if the image is of a 2D scene (a bunch of objects on a table, seen from directly above for example) unless the image is taken with scale information included (distance to table and some reference points) you have no idea of the relationship between a pixel and a metre. If you know the size of one of the objects (a reference object) then if you can automatically identify this, you can do it, but that's a pile of work all on it's own.

For a "generic" image picked at random? No chance.


这篇关于如何在WPF,vb.net中测量两个对象(图像)之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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