【问题标题】:How to assign image size based on distance如何根据距离分配图像大小
【发布时间】:2014-09-19 22:17:46
【问题描述】:

我根据预定义的(例如)距离和图像宽度和高度来分配图像大小。我参考了这些链接:link1link2

height_of_frame = ((obj_distance) * measured_object_height_in_mm / 1000.0))/focal;

width_of_frame = ((obj_distance) * measured_object_width_in_mm / 1000.0))/focal;

int imagesize_height = ((152.4)*1990/1000)/0.33;

int imagesize_width = ((152.4)*3500/1000)/0.33;

距离以厘米为单位 = 152.4,ipadMini 相机焦距为 3.3mm = 0.33cm

但是,如果我这样做,它会减小图像大小而不是靠近或靠近。

基于纵横比的图像大小:

CGFloat widthRatio = self.view.frame.size.width / enteredRoomSize.width;
 CGFloat heightRatio = self.view.frame.size.height / enteredRoomSize.height;

  CGSize imageSize = CGSizeMake(350 * widthRatio, 199 * widthRatio);

 mmageView=[[UIImageView alloc]init];

 CGRect frame = mmageView.frame; frame.size = imageSize; mmageView.frame = frame;

【问题讨论】:

  • 我编辑了我的答案以匹配您的符号,但您需要澄清您的问题......“但是,如果我这样做,它会减小图像大小而不是接近或接近”是什么意思。 ?

标签: ios objective-c image-processing augmented-reality core-motion


【解决方案1】:

这是基础数学。公式为:

object_distance = (focal * real_object_height)/object_height;

因此你应该有:

height_of_frame = (focal * measured_object_height_in_mm / 1000.0))/obj_distance;

width_of_frame = (focal  * measured_object_width_in_mm / 1000.0))/obj_distance;

另外,height_of_framefocal 具有相同的单位(通常是像素),obj_distance 的单位应该是米,而不是厘米。

【讨论】:

  • real_object_height 是什么。我正在为增强现实应用程序在相机视图上叠加图像。图像只是覆盖在相机视图上,它不在相机视图的前面
  • 我在相机覆盖层上的图像不在相机视图的前面。那么,我需要在叠加图像中使用measured_object_height_in_mm 吗?然后根据距离和焦距,我需要用高度和宽度覆盖图像
猜你喜欢
  • 2019-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多