Projection matrix

Introduction

The projection matrix P is the matrix used to convert a 3D world referenced point into a pixel (poi).

The P matrix is based in following parameters:

  • Kin
    • f
    • CCD size (width, height)
    • CCD pixels (hoz, vert)
    • Skew angle
  • Kext
    • Camera position vector Twoc (world referenced)
    • Camera rotation (yaw, pitch, roll angles) respect world axis (Rwoc)
Let’s see how to define P matrix:
P matrix definition

Figure 1 – P matrix definition

 

Demonstration

The figure 2 is a 3D blender generated scene, we know the value of Pow = [-3.6241, 4.4915, 4.9336]  (blue screen upper right corner), and we know the following parameters about camera:

  • f: 35mm (extracted from blender)
  • CCD size horizontal: 32mm (extracted from blender, is hard coded)
  • CCD size vertical: 32*(9/16) = 18mm  (calculated from CCD horizontal size assuming DAR = 16/9)
  • CCD pixels: 720×576 (render image pixels)
  • Camera position: [10 , -15, 10] (world referenced) (extracted from blender)
  • Skew angle = 90º (suppose a good aligned CCD)
  • Camera rotation (ordered) (in blender this rotation order is named ZYX Euler
    • Yaw (Z): +8º
    • Pitch (Y): +29º
    • Roll (X): +68º
We want to know which will be the pixel (poi) where Pow is projected.
3D world (blender)

Figure 2 – 3D world (blender)

In the figure 3 we can see the rendered image, you can download the image and measure that the upper right corner pixel of the screen (Pow) is [299, 154]

Rendered image (anamorphic)

Figure 3 – Rendered image (anamorphic)

But the image of figure 3 is NOT the captured image in virtual CCD of blender, the image captured by virtual CCD (front view) is vertically flipped, see figure 4

Captured image in CCD

Figure 4 – Captured image in CCD

When we define intrinsics matrix we have used the axis of CCD front view, where the image appears vertically inverted respect stored image (figure 3).

If we invert vertically the rendered image we will see that the pixel corresponding to Pow is [299, 422].

And finally only have to check if the calculated pixel is the same as rendered pixel, see figure 5.

Po to pixel calculus

Figure 5 – Po to pixel calculus

To simplify these steps you can use the following matlab function that calcs the pixel position (and other camera parameters):

 
    [poi Kin Kext Mo Rw2oc] = GetPixelFrom3DPoint ([-3.6241, 4.4915, 4.9336], 3.5, 3.2, 1.8, 720,576,90,-68,-29,-8,[10 -15 10])
(*) The camera rotation angles are negative respect blender rotations due to blender definition of rotation angles, see figure 5.
Now we have checked that this method works good. 

Using this calculus, we can know which will be the correspondence pixel of any point of the real world if we have the following parameters:

  • OC (Origin of coordinates: World origin)
  • Pow: 3D Point location (world referenced)
  • Camera f
  • CCD size (horizontal, vertical) or camera FOV
  • CCD pixels (horizontal, vertical)
  • Twoc: Camera location (world referenced)
  • CCD Skew angle (rarely used. Default = 90º)
  • Camera rotation in X,Y,Z  (ordered)

If we have the camera projection matrix (P) will be enough to calculate the pixel correspondence of any Pow, the P matrix has embedded the following parameters: OC, f, CCD size, CCD pixels, Twoc, CCD skew angle, and camera rotations.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: