Focal Length of Camera View according to Distance

1k views Asked by At

I'm working on an app related to Augmented Reality. It has a gallery that let you select the picture and frame and then a Live Camera Preview shows you how it'll look on your wall. In this live preview use set its distance from wall i.e. 1 meters to 6 meters and the picture adjusts accordingly and shows in the live camera view. For now I'm using the assumed values like:

case 1:
self.imageObject.frame = CGRectMake(self.imageObject.frame.origin.x , self.imageObject.frame.origin.y, 180, 180);            
break;

Suppose if the initial size of all the images is 200x200 pixels so what will be the formula from which I can get the exact value that if frame size is 200x200 at 1m and when it taps 2m the size changes to the exact 2m value of frame just like a real focal value. Its like distance to pixels conversion what I'm thinking.

1

There are 1 answers

0
AudioBubble On BEST ANSWER

This link might help you. What you need to do is you should know the camera focal length of iPhone camera. It'll be different for 5s, 6 or 6 plus. For a lens of focal length f corresponding to lens power P an object distance of o will produce an image at i The linear magnification will be M. The formula is 1/object distance + 1/image distance = 1/focal length. Visit the link to have a more clear idea.