Is it possible to calculate the dimensions of ANY object in a picture having at some known distance an object on know dimensions? Is it possible to calculate the dimensions of ANY object in a picture having at some known distance an object on know dimensions?
I'm thinking about the scenario where someone is holding a smartphone in one hand and on the other, or at some fixed stand, we have a W x H cm paper rectangle at some distance D cm.
Assuming some lenses characteristics, could it be possible to map the pixels to real objects and estimate their size?

I can imagine how to if we assume all the objects are in the same plane or distance, but I'd like to understand the optics principles would allow us to calculate it when the objects aren't at the same distance from the camera as is the reference object.
This question here Size of object from its image answer the question how to estimate actual dimensions of an object at some known distance. 
Another one Calculate the distance between two points from iPhone Camera answers how to estimate the distance of 2 objects in the same plane assuming you know the distance from the camera.
Regards
Joao Carlos
 A: No, simply knowing the size and distance of a single object is not good enough.
That will allow you to determine the angle between any two points in a photograph, but to know the size of a second object, you have to know the relative distances to the observer of the two objects.
Obvious example: Just including the moon in a picture doesn't tell you the size of all other objects.
A: Disclaimer: not an optics expert.
When an image is out of focus, a point of light that would have gone to a single pixel in an in-focus pixel is instead smeared over multiple pixels. There is an algorithm for undoing this called deconvolution which has been used in practice. The process of doing deconvolution involves figuring out how big the 'smearing' is, which in turn can be used to infer how far the object is from the correct focal length. Once we know how far away the objects are, we can infer how big they are.
However, as you can see, the results aren't exactly perfect. There's a lot of noise. As a result, I don't think this process would be good for anything better than an order-of-magnitude calculation. 
