When a camera is viewing an object on the flat ground, the bottom point P of the object is projected on the camera image plane. The camera coordinate system here is right handed whose view vector is x-axis and x-axis points outwards from the screen. Let ϕ∈[0,2π] be the tilt angle of the camera, then the view vector is parallel with the ground when ϕ=0 and intersects with a point on the ground when ϕ=0. Lastly, H is the camera height in meter.
1. The ground plane equation
If y-axis of the camera is rotated by ϕ around its x-axis, its y-axis will be parallel with the normal vector n of the ground. Therefore, −n is ⎝⎛1000cosϕsinϕ0−sinϕcosϕ⎠⎞⎝⎛010⎠⎞=⎝⎛0cosϕsinϕ⎠⎞=−n
So n is (0,−cosϕ,−sinϕ)t. It implies that the ground plane is the plane whose normal vector is n and distance from the camera origin is H. Therefore, the ground plane equation is H−ycosϕ−zsinϕ=0.
2. Finding P
P(x,y,z) is the object point which is on the ground plane, so this point is satisfied with the ground plane equation. Let P′(u,v,1) be the point on the image plane and K is the intrinsic matrix of the camera, then P′ can be written by KP=⎝⎛f000f02w2h1⎠⎞⎝⎛xyz⎠⎞=⎝⎛fx+2wzfy+2hzz⎠⎞≅⎝⎛zfx+2wzfy+2h1⎠⎞=⎝⎛uv1⎠⎞
where w and h are the width and height of the camera. It means P((u−2w)fz,(v−2h)fz,z), where z component of P is z=sinϕH−ycosϕ(ϕ=0) from the ground plane equation. Consequently, P is as follows. yxz=(v−2h)fsinϕH−ycosϕ⟹y=fsinϕ+(v−2h)cosϕ(v−2h)H=(u−2w)fsinϕH−ycosϕ=(u−2w)fsinϕ1(H−fsinϕ+(v−2h)cosϕ(v−2h)Hcosϕ)=fsinϕ+(v−2h)cosϕ(u−2w)H=fsinϕ1(H−fsinϕ+(v−2h)cosϕ(v−2h)Hcosϕ)=fsinϕ+(v−2h)cosϕfH
What if ϕ=0?
When ϕ=0, z=sinϕH−ycosϕ is not defined because its denominator is zero. Instead, y=H from the ground plane equation in this case. It also implies that (v−2h)fz=H and z=v−2hfH. Moreover, x=v−2h(u−2w)H from (u−2w)fz. Note that this result is the same with P as above when ϕ=0.
What if ϕ=0 and v=2h?
When ϕ=0 and v=2h, P is not defined since its all components go to infinity. But it makes sense because if the tilt angle is zero, the view vector is parallel with the ground and there is no intersection between them, or they meet at infinity.
3. Finding a point over P
Until now, P is always on the ground plane. But objects are not always on the ground and they can be over the ground. In this case, it is required that the height of the object from the ground be known. Let r be the height of the object, then it is possible to imagine that the ground plane is going up by r. It means that this point is on the new ground plane again whose distance from the camera origin is H−r, not H. Therefore, P which is over the ground can be modified as follows: xyz=fsinϕ+(v−2h)cosϕ(u−2w)(H−r)=fsinϕ+(v−2h)cosϕ(v−2w)(H−r)=fsinϕ+(v−2h)cosϕf(H−r)
4. Accuracy on the image plane
The adjacent pixel points projected on the image plane from the ground may not close enough on the ground. In other words, the points that are close on the image plane can be far from each other in the camera coordinates. (u1,v1,1)t and (u2,v2,1)t are adjacent as above, and let z1 and z2 be z components of the 3D points on the ground which are projected on them. z1z2=fsinϕ+(v1−2h)cosϕfH⟹v1=f(z1cosϕH−tanϕ)+2h=fsinϕ+(v2−2h)cosϕfH⟹v2=f(z2cosϕH−tanϕ)+2h
Now that v1 and v2 are adjacent, v2−v1=1. v2−v1=cosϕfH(z21−z11)=1⟹z21−z11=fHcosϕ
This result implies that the larger ϕ, f, and H are, the smaller ∣z1−z2∣ is, the less the distance between two 3D points from (u1,v1,1)t and (u2,v2,1)t is.
Keep going!Keep going ×2!Give me more!Thank you, thank youFar too kind!Never gonna give me up?Never gonna let me down?Turn around and desert me!You're an addict!Son of a clapper!No wayGo back to work!This is getting out of handUnbelievablePREPOSTEROUSI N S A N I T YFEED ME A STRAY CAT