The lens in the camera has some focal length $f$. The object is in front of the lens and the image is created on the camera sensor. If the distance between the object and the camera is p and the distance between the lens and the sensor is q:
$$\frac 1p+\frac1q=\frac 1f\tag{1}$$
That's famous Newton's formula. Height of the object H and height of the image h are proportional:
$$\frac Hp=\frac hq\tag{2}$$
From (2):
$$ q=\frac {ph}{H}$$
Replace that into (1) and you get:
$$\frac1p\left(1+{H \over h}\right)=\frac 1f $$
From it, you can find the size of the image $h$ as a function of distance (the formula you are looking for):
$$h=\frac{Hf}{p-f}\tag{3}$$
The only problem is that you don't know the focal distance $f$ and the height of the object $H$. But you know that for $p_1=1$m, $h_1=20$px and for $p_2=0.12$m, $h_2=80$px.
Replace that into (3) and you have the following two equations:
$$h_1=\frac{Hf}{p_1-f}$$
$$h_2=\frac{Hf}{p_2-f}$$
This is a simple system of 2 equations with 2 unknowns ($H,f$) and the solutions are:
$$f=\frac{p_1h_1-p_2h_2}{h_1-h_2}\tag{4}$$
$$H=h_1h_2\frac{p_2-p_1}{h_1p_1-h_2p_2}\tag{5}$$
Calculate $f,H$ from (4) and (5), replace into (3) and you are done.