I am designing a system to capture images of a specific object (with specific dimensions) from different distances in a way they have specific sizes in pixel.
I am looking for a solution which gives me the distance if I give it the object size in pixel in the captured image.
Although the easiest way to solve it would be to take the image from farther or closer distances and then crop, down-sample or up-sample it, I need some guideline about the exact distance which gives me the exact size in pixel in the image.
Let's put it in another way: I take a picture of an object (with size W,H) at X cm distance from the camera, and the subject size in the image is w,h. If I want the same object to be at w1,h1, what should be the distance X1 of the object from the camera? For the sake of simplicity, I assume the object is parallel to the camera so it is considered as a 2D object.