This really depend on all sorts of details, but for the idealized situation, the following data will suffice:
In addition, call the distance between the camera and the two points $L$.
The camera's field of view ($FOV$) (or angle of view as is more common in photography) can be calculated by
$$
FOV = 2\arctan\left(\frac{d}{2F}\right)
$$
which, for a scene at distance $L$ corresponds to a scene dimension $W$ equal to
$$
W = 2\cdot L\cdot\tan(FOV/2) = \frac{Ld}{F}
$$
therefore, if two objects are $x$ pixels apart, and there are $y$ pixels in that dimension, the objects are
$$
W \cdot \frac{x}{y} = \frac{Ldx}{Fy}
$$
meters apart in reality.
As always, make sure you use consistent units; often, the focal lengths will be given in millimeters, while the detector size is given in inches and the distance from the camera to the objects in feet. Choose one system, and convert everything to that single system of units before calculating anything.
Now again, this is a first approximation and only applies to an idealized setup. In reality, there are many other things to consider, but the distance between the objects will roughly follow the relation above.
If you know the specifics of the camera (lens system, aperture settings, etc.), then you can make a direct relationship between the size of the image and the angular size.
But without a distance measurement (something the camera does not do), you can't turn that into an absolute size.
If there is other information in the photograph that gives the distance, then the size can be calculated.
If all you have is the image (and not the information about the specifics of the camera), then even the angular size cannot be calculated.
Best Answer
Using the Thin Lens Equation, with object distance and focal length, work out image distance behind lens. (Or do you already know the image distance from the lens = distance between lens and screen?)
Then the ratio of image to object heights = ratio of image to object distances. Finally, convert image height in inches to number of pixels, using the resolution q = number of dpi.