File: igstkPerspectiveTransform.h

package info (click to toggle)
igstk 4.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 38,980 kB
  • sloc: cpp: 86,267; xml: 96; makefile: 75; python: 38
file content (121 lines) | stat: -rw-r--r-- 4,096 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*=========================================================================

  Program:   Image Guided Surgery Software Toolkit
  Module:    $RCSfile: igstkPerspectiveTransform.h,v $
  Language:  C++
  Date:      $Date: 2009-06-15 19:56:58 $
  Version:   $Revision: 1.2 $

  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#ifndef __igstkPerspectiveTransform_h
#define __igstkPerspectiveTransform_h

#include "igstkTransformBase.h"

#include "vtkMatrix4x4.h"
#include "vtkPerspectiveTransform.h"
#include "itkMatrix.h"

#include "igstkMacros.h"

namespace igstk 
{
 
/** \class PerspectiveTransform 
 *  \brief A class representing a 3D rigid transformation followed by a 
 *         perspective projection.
 * 
 * This class represents a perspective transform of points from 3D to 2D. 
 * 
 * All the set methods require an argument that defines the number of
 * milliseconds for which the stored information is considered to be valid.
 * The validity period will be counted from the moment the Set method was
 * invoked.
 *
 * \sa TransformBase
 *
 * */
  class PerspectiveTransform : public TransformBase
{
public:
  /** Extrinsic perspective camera parameters [R,t]*/ 
  typedef ::itk::Matrix<double, 3, 4> ExtrinsicMatrixType;
  /** Intrinsic perspective camera parameters, upper triangular matrix*/
  typedef ::itk::Matrix<double, 3, 3> IntrinsicMatrixType;

public:

  /** Constructor and destructor */
  PerspectiveTransform();
  PerspectiveTransform( const PerspectiveTransform & t );
  virtual ~PerspectiveTransform();

  /** Assign the values of one transform to another */
  const PerspectiveTransform & operator=( 
    const PerspectiveTransform & inputTransform );


  /** Set perspective transformation. This transformation will override
   * any previously set values. The information will be
   * considered valid from the time of invocation of the method until that time
   * plus the millisecondsToExpiration value. */
  void SetTransform( const ExtrinsicMatrixType &extrinsic,
                     const IntrinsicMatrixType &intrinsic,
                     ErrorType errorValue,
                     TimePeriodType millisecondsToExpiration );

 
  /** Export the content of the transformation into a vtkPerspective transform
   * which represents the rigid transform followed by the perspective 
   * projection.
   * Users must allocate the matrix first and then pass it by reference to this
   * method.  The current method will simply fill in the transform.
   */
  void ExportTransform( vtkPerspectiveTransform &outMatrix ) const;


  /** Export the extrinsic camera parameters. This is the rigid transformation
   *  between the camera and the reference frame relative to which it was 
   *  calibrated.
   */
  void ExportExtrinsicParameters( vtkMatrix4x4 & matrix ) const;


  /** Export the intrinsic camera parameters. This is the perspective 
   *  transformation associated with the internal camera parameters.
   */
  void ExportIntrinsicParameters( vtkPerspectiveTransform &outMatrix ) const;


  /** Method for printing the member variables of this class to an ostream */
  void Print( std::ostream& os, itk::Indent indent ) const;


protected:

  void PrintHeader( std::ostream& os, itk::Indent indent ) const;

  void PrintTrailer( std::ostream& itkNotUsed(os), 
                     itk::Indent itkNotUsed(indent) ) const;

  /** Print the object information in a stream. */
  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const; 

private:
  ExtrinsicMatrixType m_ExtrinsicTransform;
  IntrinsicMatrixType m_IntrinsicTransform;
};

std::ostream& operator<<( std::ostream& os, 
                          const igstk::PerspectiveTransform& o );
}

#endif