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.
 
 
 
 
 
 

60 lines
2.1 KiB

#include "basicCameraInfo.h"
#include "basicLogCollection.h"
float calcFOV_inch(float SensorSize, float FN)
{
/*
The calculator below converts between the focal length f and the field of view (FOV) of a rectilinear lens.
The formula that it implements is FOV = 2 arctan (x / (2 f)), where x is the diagonal of the film.
The FOV is measured across the frame's diagonal, and is therefore smaller across the horizontal dimension,
and even smaller across the vertical dimension.
*/
return 2.0f * atanf((SensorSize * 25.4f) / (2.0f * FN));
}
float calcFOV_mm(float SensorSize, float FN)
{
/*
The calculator below converts between the focal length f and the field of view (FOV) of a rectilinear lens.
The formula that it implements is FOV = 2 arctan (x / (2 f)), where x is the diagonal of the film.
The FOV is measured across the frame's diagonal, and is therefore smaller across the horizontal dimension,
and even smaller across the vertical dimension.
*/
return 2.0f * atanf(SensorSize / (2.0f * FN));
}
float calcMaxDistance_inch(float SensorSize, float MaxFL, int ImageWidth)
{
float tFOV, tt;
tFOV = calcFOV_inch(SensorSize, MaxFL);
tt = tFOV / ((float) ImageWidth); // 1 pixel
return .01 / tanf(tt / 2.0f); // return Distance in meters to see 1 cm as 1 pixel
}
float calcMaxDistance_mm(float SensorSize, float MaxFL, int ImageWidth)
{
float tFOV, tt;
tFOV = calcFOV_mm(SensorSize, MaxFL);
tt = tFOV / ((float) ImageWidth); // 1 pixel
return .01 / tanf(tt / 2.0f); // return Distance in meters to see 1 cm as 1 pixel
}
float calcMinDistance_mm(float SensorSize, float MaxFL, int ImageWidth)
{
float tFOV, tt;
tFOV = calcFOV_mm(SensorSize, MaxFL);
tt = tFOV / ((float) ImageWidth); // 1 pixel
return (0.01 / tanf(tt / 2.0f)) / 1.5f; // return Distance in meters to see 150 cm as ImageWidth pixel
}
float calcFL_deg(float SensorSize, float FOV)
{
return SensorSize / (2.0f * tanf(/*deg2rad(*/ FOV /*)*/ / 2.0f));
}
float calcCFL(float SensorSize, float Distance, int ImageWidth)
{
float tFOV = 2.0f * atanf(0.01f / Distance);
return calcFL_deg(SensorSize, tFOV) / 1000.0f; // in mm
}