How can I convert camera motion into zoom?

I try to reconstruct a camera of a video sequence via match moving techniques. After the reconstruction process all seemed to work as expected, but then I've realized my camera is moving forward instead of zooming into the 3d-scene like this: Every dot of the path represents the position of the camera in 3d space (Frame 1 to 40)

I know that (initial situation):

• focal length is 35mm at frame 1
• focal length is 85mm at frame 40
• the distance to the object is 0.8m

When I try to animate this values by hand (see the image below) it is unfortunately not accurate enough, because of the camera man's delay in turning the lens. Desired effect (Frame 1 to 40)

Is it mathematically possible to convert the camera motion into a zoom to get the correct focal length for every single frame?

• This seems more like applied math or even maybe engineering rather than pure mathematics. You might get a better reply asking on a different stack exchange. Perhaps Video Production, or Photography. Doesn't the signal processing stack exchange also discuss image techniques? One of those my prove more fruitful. – Stan Shunpike Jan 9 '15 at 21:21
• Thanks for your answer @StanShunpike - never heard of dsp -will looking into it. Thought for mathematicians it's a nice and easy to solve issue, but it seems not to be :) – p2or Jan 9 '15 at 21:26
• Part of using Stack Exchanges well appears to be not merely whether people can solve the problems but also if they find them useful or interesting. But each community has it's own definition of "interesting" and sometimes they even disagree. I learned this by trial and error since I joined. – Stan Shunpike Jan 9 '15 at 21:28
• @StanShunpike thanks. Try to understand it :) – p2or Jan 9 '15 at 21:34
• In perfection, this is not possible, i.e. the depicted images will differ: If you zoom in, all objects keep their perceived size ratios (e.g. a person in front may be as tall as the Eiffel tower - and this does not change when zooming). On the other hand, the size ratios change when the camera is moving (e.g. a person in front quickly grows bigger whereas the Eiffel tower at the horizon keeps its perceived size). There is even a special effect used in (horror)filmmaking that makes use of this effect: If you move and zoom so that in effect the actor keeps his size, the walls seem to move away. – Hagen von Eitzen Jan 11 '15 at 13:11

in short

You can calculate the focal length of the zooming camera $f_z$ $$f_z = \frac{d_z f_m}{d_m}$$ with $d_z$ the distance to the object from the zooming camera. $f_m$ represents the focal length of the the moving camera and $d_m$ represents the distance to the object from the moving camera.

explanation

You can use the magnification formula to calculate the magnification $m$ with the focal length $f$ and the distance to the object $d$. $$M = \frac{f}{d - f}$$ While you want to have the same magnification for the camera in motion and the camera in zooming mode $m_m = m_z$ the equation will look like this: $$\frac{f_m}{d_m - f_m} = \frac{f_z}{d_z - f_z}$$ Solving this for $f_z$:

$$f_z = \frac{d_z f_m}{d_m}$$

example

So if the camera that should zoom has a distance to the object of $800mm$ and the camera that is in motion has a focal length of $35mm$, the focus length of the zooming camera is $$f_z = \frac{800mm \times 35mm}{d_m}$$ while $d_m$ is the distance to the object from the moving camera in the current frame.

If you can identify items in the picture to find the width of the frame as a function of frame number you can do it. As the distance to the object is large compared to the focal lengths, the size of the object in the frame is inversely proportional to the focal length. If $W$ is the width of what you can see in frame $1$ and $W'$ is the width of what you can see in some other frame, you have $35W=fW'$ or $f=35\frac W{W'}$ where $f$ is the focal length in that frame in mm.

• Thanks Ross! Why it's not possible to convert the camera motion instead of checking object distance? – p2or Jan 9 '15 at 21:49
• I don't understand the question. I took it that the camera was fixed and all that was happening was the lens was zooming. Is that not correct? – Ross Millikan Jan 9 '15 at 22:05
• Yes, after the calculation the camera should zooming instead of moving forwards. :) Is it really necessary to to have an object (W) to calculate this? Why we can't only determine this by the position change of the camera? – p2or Jan 9 '15 at 23:54
• @Poor what do you mean by "object" $W$? $W$ doesn't stand for an object. Ross defined that as the width of what you can u can see in a given frame – Stan Shunpike Jan 10 '15 at 1:43
• You can imagine that there is a measuring stick across the frame. As you zoom in, you can see less and less of the stick. $W$ and $W'$ are the total width you can see in the frame. – Ross Millikan Jan 10 '15 at 2:16