sugr
Class ProjectiveCamera

java.lang.Object
  extended bysugr.Element
      extended bysugr.Transformation
          extended bysugr.ProjectiveCamera
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class ProjectiveCamera
extends Transformation

This class represents a projective camera. This camera consists of:

Internel the camera parameters are stored as a projection matrix P. Like every transformation, P is stored as stacked columns in vector v. Translation and Rotation are known as exterior orientation (camera to world- coordinate-system), the parameters above specify inner orientation of the camera. Both types together gives the projection matrix (3x4), to project a 3D-Point into a 2D-Point.
         | c   cs   ppX |     | r11 r12 r13 t1 |         | p11 p12 p13 p14 |      
         | 0 c(1+m) ppY |  *  | r21 r22 r23 t2 |    =    | p21 p22 p23 p24 |
         | 0    0    1  |     | r31 r32 r33 t3 |         | p31 p32 p33 p34 |

           inner orient.        exterior orient.          projection matrix
              (3x3)                 (3x4)                      (3x4)
 
If you use getCov(), you get covariance for Point-Transformations. If you like to transform 3D-Lines, you can get this transformation-matrix via getLineMatrix() and its covariance via getLineMatrixCov().

Author:
Norbert Fischer
See Also:
Serialized Form

Field Summary
private static int DIM
           
private static int DIMC
          Number of cols of projection matrix
private static int DIMR
          Number of rows of projection matrix
private static int DOF
           
private  Matrix P
          Stores the Point-Projection and Line-Projection matrices (for speed-optimisation only)
private  Matrix Q
          Stores the Point-Projection and Line-Projection matrices (for speed-optimisation only)
private  Matrix Qdual
          Stores the Point-Projection and Line-Projection matrices (for speed-optimisation only)
private static long serialVersionUID
          Class version number for serialization
 
Fields inherited from class sugr.Element
cov, MAXITER, v
 
Constructor Summary
ProjectiveCamera()
          Default constructor
ProjectiveCamera(double c)
          Sets a ProjectiveCamera by only defining camera constant.
ProjectiveCamera(double[] cam)
          Sets a ProjectiveCamera by setting whole projection matrix.
ProjectiveCamera(double[] cam, Matrix cov)
          Sets a ProjectiveCamera by setting whole projection matrix.
ProjectiveCamera(double c, double ppX, double ppY)
          Sets a ProjectiveCamera by camera constant and principal point (camera with euclidean sensor)
Exterior orientation is set to identity.
ProjectiveCamera(double c, double shear, double scale, double ppX, double ppY)
          Sets a ProjectiveCamera by setting inner orientation parameters directly.
ProjectiveCamera(double p11, double p12, double p13, double p14, double p21, double p22, double p23, double p24, double p31, double p32, double p33, double p34)
          creates a PojectiveCamera from the 12 entries of the point projection matrix: | p11 p12 p13 p14 | | p21 p22 p23 p24 | | p31 p32 p33 p34 |
ProjectiveCamera(double p11, double p12, double p13, double p14, double p21, double p22, double p23, double p24, double p31, double p32, double p33, double p34, Matrix cov)
          Sets a ProjectiveCamera by setting whole projection matrix.
ProjectiveCamera(double c, double shear, double scale, double ppX, double ppY, Matrix cov)
          Sets a ProjectiveCamera with covariance by setting inner orientation parameters directly.
ProjectiveCamera(double c, double ppX, double ppY, Matrix cov)
          Sets a ProjectiveCamera by camera constant and principal point (camera with euclidean sensor)
Exterior orientation is set to identity.
ProjectiveCamera(double c, Matrix cov)
          Sets a ProjectiveCamera with covariance by only defining camera constant.
ProjectiveCamera(Matrix pointMatrix)
          Creates a ProjectiveCamera from a 3x4 point projection matrix
ProjectiveCamera(Matrix inOrien, Matrix extOrien)
          Creates a ProjectiveCamera by setting inner and exterior orientation.
ProjectiveCamera(Matrix inOrien, Matrix extOrien, Matrix cov)
          Creates a ProjectiveCamera by setting inner and exterior orientation with covariance.
ProjectiveCamera(Matrix inOrien, Motion_3D extOrien)
          Creates a ProjectiveCamera by setting inner and exterior orientation.
ProjectiveCamera(Matrix inOrien, Motion_3D extOrien, Matrix cov)
          Creates a ProjectiveCamera by setting inner and exterior orientation.
ProjectiveCamera(Motion_3D extOrien)
          Creates a ProjectiveCamera by setting exterior orientation.
ProjectiveCamera(Motion_3D extOrien, Matrix cov)
          Creates a ProjectiveCamera by setting exterior orientation with covariance.
ProjectiveCamera(java.io.Reader r)
          Reads a projection matrix from a Reader.
ProjectiveCamera(Translation_3D trans, Rotation_3D rot)
          Creates a ProjectiveCamera by setting exterior orientation.
ProjectiveCamera(Translation_3D trans, Rotation_3D rot, Matrix cov)
          Creates a ProjectiveCamera by setting exterior orientation.
 
Method Summary
private  void calcProjectionMatrices()
           
 void doCondition(double[] f)
          Condition that element with a set of conditioning factors.
 Matrix getCalibrationMatrix()
          Returns the calibration matrix containing the interior orientation parameters
 int getDegreesOfFreedom()
          returns the degrees of freedom of the projective camera
 int getDimCol()
          Get the number of columns of the transformation matrix.
 int getDimRow()
          Get the number of rows of the transformation matrix.
 Matrix getDualLineMatrix()
           
 Matrix getInversePointMatrix(Vector A)
          Returns the Inverse Point Projection Matrix of the plane A.
 Matrix getJacobianAfterFirst(Entity e)
          The the Jacobian after the first entity of a trilinear relation.
 Matrix getJacobianAfterSecond(Entity e)
          The the Jacobian after the second entity of a trilinear relation.
 Matrix getLineMatrix()
           
 Matrix getPointMatrix()
           
 Plane_3D getPrincipalPlane()
          Returns the principal plane of the camera
 Point_3D getProjectionCenter()
          Returns the projection center of the camera
 Matrix getRotationMatrix()
          Returns the rotation matrix from the world to the camera coordiante system
 void swapRC()
          Swaps the first two lines of the transformation matrix This is needed to support RC- and XY-coordinate-systems
 Entity transform(Entity e)
          This method invokes the appropriate transform, if the Object has been downcasted
 Plane_3D transform(Line_2D l)
          Performes the inverse projection of an 2D-line
 Line_2D transform(Line_3D l)
          Performes the projection of a 3D line
 Line_3D transform(Point_2D p)
          Performes the inverse projection of an 2D-point
 Point_2D transform(Point_3D p)
          Performes the projection of a 3D point
 
Methods inherited from class sugr.Transformation
errorProp, getDimension, getJacobianOfRelation, getReducedAB, getTransformationMatrix, getTransposeTransMatrix, transform
 
Methods inherited from class sugr.Element
approximate, calcCov, changeNullspace, changeNullspace, checkCovDim, checkElement, clone, ensureConstraints, estimate, estimate, gaussHelmertIterations, gaussHelmertIterationsOld, getConstraintValue, getCov, getJacobianOfConstraint, getV, normalizeSphere, normalizeSphereComparable, print, print, reduceFirstMatrix, reduceMatrix, reduceMatrix, setCov, setV, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Class version number for serialization

See Also:
Constant Field Values

DIM

private static final int DIM
See Also:
Constant Field Values

DIMR

private static final int DIMR
Number of rows of projection matrix

See Also:
Constant Field Values

DIMC

private static final int DIMC
Number of cols of projection matrix

See Also:
Constant Field Values

DOF

private static final int DOF
See Also:
Constant Field Values

P

private Matrix P
Stores the Point-Projection and Line-Projection matrices (for speed-optimisation only)


Q

private Matrix Q
Stores the Point-Projection and Line-Projection matrices (for speed-optimisation only)


Qdual

private Matrix Qdual
Stores the Point-Projection and Line-Projection matrices (for speed-optimisation only)

Constructor Detail

ProjectiveCamera

public ProjectiveCamera()
Default constructor


ProjectiveCamera

public ProjectiveCamera(Matrix pointMatrix)
Creates a ProjectiveCamera from a 3x4 point projection matrix

Parameters:
pointMatrix - The 3x4 point projection matrix

ProjectiveCamera

public ProjectiveCamera(double p11,
                        double p12,
                        double p13,
                        double p14,
                        double p21,
                        double p22,
                        double p23,
                        double p24,
                        double p31,
                        double p32,
                        double p33,
                        double p34)
creates a PojectiveCamera from the 12 entries of the point projection matrix:
    | p11  p12 p13 p14 |
    | p21  p22 p23 p24 |
    | p31  p32 p33 p34 |
 

Parameters:
p11 - Entry of the 3x4 point projection matrix
p12 - Entry of the 3x4 point projection matrix
p13 - Entry of the 3x4 point projection matrix
p14 - Entry of the 3x4 point projection matrix
p21 - Entry of the 3x4 point projection matrix
p22 - Entry of the 3x4 point projection matrix
p23 - Entry of the 3x4 point projection matrix
p24 - Entry of the 3x4 point projection matrix
p31 - Entry of the 3x4 point projection matrix
p32 - Entry of the 3x4 point projection matrix
p33 - Entry of the 3x4 point projection matrix
p34 - Entry of the 3x4 point projection matrix

ProjectiveCamera

public ProjectiveCamera(java.io.Reader r)
                 throws java.io.IOException
Reads a projection matrix from a Reader. The purpose of this constructor is to read the camrea parameters from an input file.

Parameters:
r - stream Reader, that yields 12 double values for the point projection matrix

ProjectiveCamera

public ProjectiveCamera(Matrix inOrien,
                        Matrix extOrien)
Creates a ProjectiveCamera by setting inner and exterior orientation. Matrices should have this form:
         | c   cs   ppX |     | r11 r12 r13 t1 |
         | 0 c(1+m) ppY |  *  | r21 r22 r23 t2 | 
         | 0    0    1  |     | r31 r32 r33 t3 | 

           inner orient.        exterior orient. 
              (3x3)                 (3x4)        
 

Parameters:
inOrien - 3x3-matrix
extOrien - 3x4 matrix

ProjectiveCamera

public ProjectiveCamera(Matrix inOrien,
                        Matrix extOrien,
                        Matrix cov)
Creates a ProjectiveCamera by setting inner and exterior orientation with covariance. Matrices should have this form:
         | c   cs   ppX |     | r11 r12 r13 t1 |
         | 0 c(1+m) ppY |  *  | r21 r22 r23 t2 | 
         | 0    0    1  |     | r31 r32 r33 t3 | 

           inner orient.        exterior orient. 
              (3x3)                 (3x4)        
 

Parameters:
inOrien - 3x3-matrix
extOrien - 3x4 matrix
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(Motion_3D extOrien)
Creates a ProjectiveCamera by setting exterior orientation. Inner orientation is set to identity

Parameters:
extOrien - a Motion_3D

ProjectiveCamera

public ProjectiveCamera(Motion_3D extOrien,
                        Matrix cov)
Creates a ProjectiveCamera by setting exterior orientation with covariance. Inner orientation is set to identity

Parameters:
extOrien - a Motion_3D
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(Matrix inOrien,
                        Motion_3D extOrien)
Creates a ProjectiveCamera by setting inner and exterior orientation. Matrix should have this form:
         | c   cs   ppX |        
         | 0 c(1+m) ppY |  
         | 0    0    1  |  
 
Error propagation is done automatically

Parameters:
inOrien - 3x3 Matrix
extOrien - a Motion_3D

ProjectiveCamera

public ProjectiveCamera(Matrix inOrien,
                        Motion_3D extOrien,
                        Matrix cov)
Creates a ProjectiveCamera by setting inner and exterior orientation. Matrix should have this form:
         | c   cs   ppX |        
         | 0 c(1+m) ppY |  
         | 0    0    1  |  
 

Parameters:
inOrien - 3x3 Matrix
extOrien - a Motion_3D
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(double c,
                        double shear,
                        double scale,
                        double ppX,
                        double ppY)
Sets a ProjectiveCamera by setting inner orientation parameters directly. Exterior orientation is set to identity

Parameters:
c - camera constant
shear - as name says
scale - as name says
ppX - principal point x-axis
ppY - principal point y-axis

ProjectiveCamera

public ProjectiveCamera(double c,
                        double shear,
                        double scale,
                        double ppX,
                        double ppY,
                        Matrix cov)
Sets a ProjectiveCamera with covariance by setting inner orientation parameters directly. Exterior orientation is set to identity

Parameters:
c - camera constant
shear - as name says
scale - as name says
ppX - principal point x-axis
ppY - principal point y-axis
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(Translation_3D trans,
                        Rotation_3D rot)
Creates a ProjectiveCamera by setting exterior orientation. Inner orientation is set to identity

Parameters:
trans - a Translation_3D
rot - a Rotation_3D

ProjectiveCamera

public ProjectiveCamera(Translation_3D trans,
                        Rotation_3D rot,
                        Matrix cov)
Creates a ProjectiveCamera by setting exterior orientation. Inner orientation is set to identity

Parameters:
trans - a Translation_3D
rot - a Rotation_3D
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(double[] cam)
Sets a ProjectiveCamera by setting whole projection matrix. It's built by:
    | a[0] a[1] a[ 2] a[ 3] |
    | a[4] a[5] a[ 6] a[ 7] |
    | a[8] a[9] a[10] a[11] |
 
TODO: same row-column index order in homograpy and projective camera

Parameters:
cam - double-Array with 12 entries

ProjectiveCamera

public ProjectiveCamera(double[] cam,
                        Matrix cov)
Sets a ProjectiveCamera by setting whole projection matrix. It's build by:
    | a[0] a[1] a[ 2] a[ 3] |
    | a[4] a[5] a[ 6] a[ 7] |
    | a[8] a[9] a[10] a[11] |
 
Covariance is also used here.

Parameters:
cam - double-Array with 12 entries
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(double c)
Sets a ProjectiveCamera by only defining camera constant. Exterior orientation is set to identity.

Parameters:
c - camera constant

ProjectiveCamera

public ProjectiveCamera(double c,
                        Matrix cov)
Sets a ProjectiveCamera with covariance by only defining camera constant. (ideal camera)
Exterior orientation is set to identity.

Parameters:
c - camera constant
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(double c,
                        double ppX,
                        double ppY)
Sets a ProjectiveCamera by camera constant and principal point (camera with euclidean sensor)
Exterior orientation is set to identity.

Parameters:
c - camera constant
ppX - principal point x-axis
ppY - principal point y-axis

ProjectiveCamera

public ProjectiveCamera(double c,
                        double ppX,
                        double ppY,
                        Matrix cov)
Sets a ProjectiveCamera by camera constant and principal point (camera with euclidean sensor)
Exterior orientation is set to identity.

Parameters:
c - camera constant
ppX - principal point x-axis
ppY - principal point y-axis
cov - 12x12 Matrix

ProjectiveCamera

public ProjectiveCamera(double p11,
                        double p12,
                        double p13,
                        double p14,
                        double p21,
                        double p22,
                        double p23,
                        double p24,
                        double p31,
                        double p32,
                        double p33,
                        double p34,
                        Matrix cov)
Sets a ProjectiveCamera by setting whole projection matrix. It's build by:
    | p11  p12 p13 p14 |
    | p21  p22 p23 p24 |
    | p31  p32 p33 p34 |
 
Covariance is also used here.

Parameters:
cov - 12x12 Matrix
Method Detail

swapRC

public void swapRC()
Swaps the first two lines of the transformation matrix This is needed to support RC- and XY-coordinate-systems


getDimRow

public int getDimRow()
Get the number of rows of the transformation matrix.

Specified by:
getDimRow in class Transformation
Returns:
the number of rows of the transformation matrix.

getDimCol

public int getDimCol()
Get the number of columns of the transformation matrix.

Specified by:
getDimCol in class Transformation
Returns:
the number of columns of the transformation matrix.

calcProjectionMatrices

private void calcProjectionMatrices()

getPointMatrix

public Matrix getPointMatrix()

getLineMatrix

public Matrix getLineMatrix()

getDualLineMatrix

public Matrix getDualLineMatrix()

getPrincipalPlane

public Plane_3D getPrincipalPlane()
Returns the principal plane of the camera

Returns:
last row of the PointProjectionMatrix

getProjectionCenter

public Point_3D getProjectionCenter()
Returns the projection center of the camera

Returns:
projection center

getRotationMatrix

public Matrix getRotationMatrix()
Returns the rotation matrix from the world to the camera coordiante system

Returns:
world to camera rotation matrix

getCalibrationMatrix

public Matrix getCalibrationMatrix()
Returns the calibration matrix containing the interior orientation parameters

Returns:
calibration matrix

getInversePointMatrix

public Matrix getInversePointMatrix(Vector A)
Returns the Inverse Point Projection Matrix of the plane A. Multiplying an image point with this matrix yields the 3D-Point lying on the plane A.

Parameters:
A - the plane
Returns:
Inverse Point Projection Matrix

transform

public Line_3D transform(Point_2D p)
Performes the inverse projection of an 2D-point

Parameters:
p - the 2D point to be inverse projected
Returns:
the 3D-line, that is obtained by inverse projection of the 2D-point TODO: Check this

transform

public Plane_3D transform(Line_2D l)
Performes the inverse projection of an 2D-line

Parameters:
l - the 2D line to be inverse projected
Returns:
the 3D plane, that is obtained by inverse projection of the 2D line TODO: Check this

transform

public Point_2D transform(Point_3D p)
Performes the projection of a 3D point

Parameters:
p - the 3D point to be projected
Returns:
the 2D point obtained by projecting the 3D point

transform

public Line_2D transform(Line_3D l)
Performes the projection of a 3D line

Parameters:
l - 3D line to be projected
Returns:
the 2D line, that is obtained by projecting the 3D line TODO: Check this

transform

public Entity transform(Entity e)
This method invokes the appropriate transform, if the Object has been downcasted

Specified by:
transform in class Transformation
Parameters:
e - entity to be transformed
Returns:
transformed entity or null, if entity is not transformable

getDegreesOfFreedom

public int getDegreesOfFreedom()
returns the degrees of freedom of the projective camera

Specified by:
getDegreesOfFreedom in class Transformation
Returns:
always 11

doCondition

public void doCondition(double[] f)
Condition that element with a set of conditioning factors. Because the stored homography matrix is the one for points, the condition-factor-matrix for Point_3D and Point_2D is used.

Specified by:
doCondition in class Element
Parameters:
f - conditioning factors ( two factors for transformations!)

getJacobianAfterFirst

public Matrix getJacobianAfterFirst(Entity e)
The the Jacobian after the first entity of a trilinear relation. For this computation the second entity and the unkown=transformation is needed.

Specified by:
getJacobianAfterFirst in class Transformation
Parameters:
e - the second Entity of the relation.

getJacobianAfterSecond

public Matrix getJacobianAfterSecond(Entity e)
The the Jacobian after the second entity of a trilinear relation. For this computation the first entity and the unkown=transformation is needed.

Specified by:
getJacobianAfterSecond in class Transformation
Parameters:
e - the first Entity of the relation.