You can detect person/face/something to get (x,y) value for each person of interest. After that you need to transform your image from image to planar scale. Homography is the term you are looking for to do that. See opencv 1 docs for info on this. Now you can compute the distances between all pairs of points.