Measuring the distance to a detected face

Posts: 18
Joined: Fri Jan 25, 2019 3:36 pm

Measuring the distance to a detected face

Postby xgarbxgarb » Tue Feb 18, 2020 11:53 am

I'm trying to calculate the distance to a detected face using the measurements from the net_boxes array.

I found this calculation from ... in-a-photo


Using the measurements:
Focal length: 45
Real face height: 200mm
Image height : 240px (QVGA)
h (the pixel height of the face from the net_boxes array)
Sensor height: 2.7mm (1/4 inch sensor)

and using code similar to below

Code: Select all

static void draw_face_boxes(dl_matrix3du_t *image_matrix, box_array_t *boxes)
  int h, i;
  for (i = 0; i < boxes->len; i++) {

    h = (int)boxes->box[i].box_p[3] - y + 1;

    int eq_top = 45 * 200 * 240; //f(mm) x real height(mm) x image height(px)
    int eq_bottom = h * 2.7; //object height(px) x sensor height(mm)

    int face_distance = eq_top/eq_bottom;

The results aren't accurate.

Is one of the measurements incorrect or is this an optics issue?

Who is online

Users browsing this forum: No registered users and 13 guests