Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
calibration.cpp
1 /***************************************************************************
2  * calibration.cpp - Abstract class defining a camera calibration matrix K
3  * for a finite camera
4  *
5  * Created: Thu May 08 13:24:00 2008
6  * Copyright 2008 Christof Rath <c.rath@student.tugraz.at>
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <fvmodels/camera/calibration.h>
25 #include <iostream>
26 #include <core/exceptions/software.h>
27 
28 using namespace fawkes;
29 
30 namespace firevision {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 /** @class Calibration <fvmodels/camera/calibration.h>
36  * A Calibration matrix for a finite camera.
37  *
38  * @author Christof Rath
39  */
40 
41 /** Hidden default constructor.
42  */
43 Calibration::Calibration(): Matrix(3, 3)
44 {
45  id();
46 }
47 
48 /** Constructor.
49  * @param k 3x3 Calibration matrix of the camera
50  */
52 {
53  K(k);
54 }
55 
56 /** Copy Constructor.
57  * @param cal the Calibration to copy
58  */
60 {
61  K(cal.K());
62 }
63 
64 /** Destructor.
65  */
67 {
68 }
69 
70 /** Calibration getter.
71  * @return The calibration matrix
72  */
73 Matrix
75 {
76  return get_submatrix(0, 0, 3, 3);
77 }
78 
79 /** Sets the calibration matrix.
80  * The matrix k has a size 3x3. The elements (row by row):
81  * scale factor in x-direction, skew, x-coordinate of the principal point
82  * 0, scale factor in y-direction, y-coordinate of the principal point
83  * 0, 0, 1
84  * @param k the calibration matrix
85  * @return reference to this instance
86  */
89 {
90  unsigned int i,j;
91  k.size(i, j);
92 
93  if (i != j || i != 3)
94  throw IllegalArgumentException("The calibration matrix has to be 3 by 3");
95 
96  id();
97  overlay (0, 0, k);
98  return *this;
99 }
100 
101 } // end namespace firevision