0
\$\begingroup\$

Let's say I take an image with a camera, mounted on a stepper motor that can rotate it in the X-direction (Yaw).

From an image taken by the camera, I can determine the required angular displacement of the camera in pixels in a certain rotational direction.

Let's say that the stepper motor has 200 steps in a 360 degree rotation. Therefore the degree/step of the stepper motor 1.8 degrees.
Let's also say that the resolution of the images taken by the camera is 1280x960 pixels.
Let's also say that the camera has a pixel size of 3.75 µm.
Let's also say that the focal length of the lens of the camera is 300 mm.

Using the known required angular displacement in pixels and the other known pieces of data, would it be possible for me to determine the required displacement in motor steps? What would the formula for that be?

Let's say that I would like the camera to move 20 pixels to the left. How would I determine how many steps of the motor that would be, in the desired direction?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You would also need to account for the lens' projection and geometric distortion. Most lenses do not magnify the entire field equally, particularly not rectilinear projection lenses, which is almost certainly what your 300mm lens would be. 20 pixels on the left and right edges would not be the same angular displacement as 20 pixels in the center. How much it would differ would depend on the lens, but in general there would be less difference with a prime lens while a zoom will almost always have pincushion distortion, and more of it, at the longer ends of the focal length range. \$\endgroup\$
    – Michael C
    Feb 28, 2023 at 4:15
  • \$\begingroup\$ Is the focal length of the lens actual focal length or the full-frame equivalent? If it's the actual focal length, you have approximately a 22163mm full-frame equivalent focal length (really large focal length!!). Perhaps you mean your lens has a full-frame equivalence of 300 mm which means your actual focal length is 41.6 mm = 300/7.21 (7.21 is the approximate crop factor for a 4.8mm wide sensor with 4:3 aspect ratio). Either way, the resolution of your stepper is too coarse. You need a micro-stepper. \$\endgroup\$
    – qrk
    Mar 1, 2023 at 0:37

2 Answers 2

1
\$\begingroup\$

That seems far more complex than it needs to be... the horizontal angle of view (AOV) for a 300mm is 6.9˚ and each step of the motor is 1.8˚...

6.9 ÷ 1.8 = 3.83 steps to replace the lens' AOV with the adjacent scene.

If you want it to be 20 pixels it would be 6.9 ÷ 1280 = .0054˚/pixel x 20 pixels = .11˚ of rotation; which your stepper motor can't do. It can do 1.8˚ ÷ .0054˚ per pixel = 333.33 pixels per step.

If you then wanted to relate this to a specific object within the scene you would need to know it's distance... how many pixels it occupies in the initial image.

You only then need to decide how much overlap you want. And you need to use the effective lens FOV if using other than a 35mm/FF sensor. Sometimes you can find that spec in the manufacturer's documentation, but sometimes not... e.g. Nikon only gives the diagonal AOV spec and only on FF. But FL and AOV are the same thing, so you can use a calculator to determine what the HAOV for a given FL and crop factor should be.

The main caveat to using a calculator is that the lens' stated FL may not be exactly correct... i.e. a 300mm lens may actually be 292mm or 310mm.


Edit: The actual sensor size/crop factor implied from the information given correlates to a 1/3 sensor with a crop factor of 7.21. Using the calculator provided, that gives a HOAV of 0.9˚.

enter image description here

0.9˚ HOAV ÷ 1.8˚ rotation = .5˚ steps to replace the entire FOV...

\$\endgroup\$
2
  • \$\begingroup\$ "AOV for a 300mm is 6.9˚" depends on the sensor size, and the OP's description implies a 3.6*4.8mm sensor size, resulting in a 1.14˚ AOV (diagonal). \$\endgroup\$ Mar 1, 2023 at 10:12
  • \$\begingroup\$ @RalfKleberhoff, Yes AOV does depend on sensor size; and I included that in my answer. I did however fail to calculate sensor size with given pitch/resolution. I'll edit to include that. \$\endgroup\$ Mar 1, 2023 at 14:36
0
\$\begingroup\$

TL;DR: In your setting, 20 pixels correspond to approximately 0.014 degrees. This is less than 1/100th of a step with your stepper motor (if that motor directly drives the mount).

Let's first ignore the geometric distortion of your lens and assume it does a mathematically simple central projection.

With your telephoto focal length, we can also ignore that the tangens function is mathematically necessary, and approximate it by the angle itself (in radians).

Then, 20 pixels mean 20 * 3.75µm, being 75µm. In relation to the focal length 300mm, we get an angle of 75µm/300mm = 0.00025 rad = 0.014 degrees.

If you want to directly rotate your camera mount with your stepper motor, then its resolution is much too coarse. One 1.8-degrees step will give a movement of 2500 pixels, completely pushing your object of interest out of the field of view. You need a reduction gear in the range of 1:1000 to achieve a useful resolution.

The given calculations are only the first approximation.

If you want to center the object in one step, you surely need to calibrate your setting. First of all, a published 300mm focal length typically means something between 250 and 350mm. And you have to account for distortions, to find out with a reference scene which angle corresponds to which pixel displacement. As lenses are typically rotation-symmetric, you need to do this only along one axis (from center to one corner), and can apply that curve for all directions.

But maybe, it's sufficient to do the centering step by step, with the first step bringing you close to the center, then measuring the remaining offset, correcting that, until you reach alignment. Then knowing the approximate focal length should be enough to get into alignment in three or four steps.

\$\endgroup\$
1
  • \$\begingroup\$ 0.014˚ is the apex of an isosceles triangle with a 75um (20px) base and 300000um (300mm) height... it seems you are calculating the movement as being within the lens/system itself? \$\endgroup\$ Feb 28, 2023 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.