You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
779 B

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "basicCameraInfo.h"
  2. float calcFOV(float SensorSize, float FN){
  3. /*
  4. The calculator below converts between the focal length f and the field of view (FOV) of a rectilinear lens.
  5. The formula that it implements is FOV = 2 arctan (x / (2 f)), where x is the diagonal of the film.
  6. The FOV is measured across the frame's diagonal, and is therefore smaller across the horizontal dimension,
  7. and even smaller across the vertical dimension.
  8. */
  9. return 2.f * atanf((SensorSize * 25.4f) / (2.f * FN));
  10. };
  11. float calcMaxDistance(float SensorSize, float MaxFL, int ImageWidth ){
  12. double tFOV, tt;
  13. tFOV = calcFOV(SensorSize, MaxFL);
  14. tt = tFOV / ((float)ImageWidth); // 1 pixel
  15. return .01 / tan(tt / 2.0); // return Distance in meters to see 1 cm as 1 pixel
  16. };