The focal_dist parameter is used by VidiReports to estimate the distance of viewers from the camera. Distance estimation works only for cameras used in a fixed-focus mode. 

Requirements

  • Excel spreadsheet for the calculation of the focal_dist parameter (attached to this article).
  • a rectangular object with a known width of x cm (e.g. a piece of cut cardboard); ideally, the width of the object should be at least 50 cm;
  • calibration of the space in front of the camera with distance marks on the floor at regular intervals (say, every half meter for a total of 6 meters).


Procedure

  • In the Excel spreadsheet, set the length (horizontal) of the object, and the width of the resolution in pixels (eg 1280 for 1280x720)

  • In the Excel spreadsheet, set the 4 distances at which you want to place the object

  • For each distance mark, place the rectangular object at the mark and take a snapshot (or a short video) of the object with the camera.

  • Analyze each snapshot with an image editor and measure the width of the object in pixels
  • Report the value in the Excel spreadsheet, in front of the corresponding distance

Theory


Let's call the width in Pixel p
i, where di is the pre-determined distance between the camera and the object relative to the i-th snapshot.

The focal distance in pixels can be determined from each snapshot by the proportionality relation

(x/2) : di = (pi/2) : f

as shown in the following figure:


Defining the focal distance

  • f should be the same for each snapshot (i.e. f = pidi/x for all i’s). In practice, multiple measurements should minimize the experimental errors due to non-integer pixel sizes and distance imprecisions and the final focal length should be the average of the focal lengths computed over each snapshot.
  • the parameter to insert in the configuration file is the normalized focal length, i.e. the average focal length above divided by the width w in pixels of the snapshots:
  • focal_dist = f/w