0

I'm assigning the image size based on the predefined (for example) distance and image width & height. I referred these links: 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;

distance in cm = 152.4 and ipadMini camera focal length is 3.3mm = 0.33cm

But, if i do this it reducing the image size not close or near.

Imagesize based on aspect ratio:

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;
Community
  • 1
  • 1
raj raj
  • 39
  • 2
  • 7
  • I edited my answer to match your notations, but you need to clarify your question... What do you mean by "But, if i do this it reducing the image size not close or near." ? – BConic Jul 28 '14 at 19:42

1 Answers1

0

This is basic mathematics. The formula is:

object_distance = (focal * real_object_height)/object_height;

Hence you should have:

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;

Also, height_of_frame will have the same unit as focal (usually pixels) and obj_distance should be in meters, not in centimeters.

BConic
  • 8,750
  • 2
  • 29
  • 55
  • What is real_object_height. I'm overlaying images on the camera view for augmented Reality application. The images just overlaying on the camera view, it isn't in-front of cameraview – raj raj Jul 28 '14 at 17:15
  • I have image on the camera overlay not in-front of the camera view. So, do i need to use measured_object_height_in_mm in the overlay image? Then based on the distance and focal length i need to overlay the image with height & width – raj raj Jul 29 '14 at 13:48