我根据预定义(例如)距离和图像宽度&分配图像大小。高度。我引用了这些链接:link1 link2
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;
距离cm = 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;
答案 0 :(得分:0)
这是基础数学。公式是:
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_frame
与focal
具有相同的单位(通常为像素),obj_distance
应以米为单位,而不是以厘米为单位。