Then you need to know the target plane U1xu2 (12.8 mmx9.6 mm) of the photosensitive chip of your camera. General cameras have this parameter.
Then get the FOV of the field of view you want to shoot (that is, the size of the field of view you want to shoot, such as 10cmX6cm) and the working distance WD (that is, the distance from the front end of the lens to the shooting target).
Unify the units of target plane, field of vision and working distance, such as converting all units into mm.
Generally, the lens takes mm as the unit, and the focal length of F lens is calculated by wide side. According to similar triangles algorithm, the following formula is given:
F=WD*U 1/FOV, that is, focal length = working distance * width of target surface/width of field of view, to obtain a focal length value, then select the long side to calculate another focal length value, and select the smaller one from these two focal length values as the focal length value. If the focal length values of 16mm and 25mm are obtained, 16mm should be selected. Why choose a small one? Just look at the calculation formula or practice.
Choose the lens with the corresponding focal length according to the interface of your camera.
If a zoom lens is needed, the calculation method is the same. Fixed-focus lenses will be used more in general industrial applications.
In fact, the easiest way is to let the person who sells industrial lenses do the calculation for you, haha, saving time and effort.