Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ccd_calibration.cpp
1 /***************************************************************************
2  * ccd_calibration.cpp - Class defining a ccd camera calibration matrix K
3  *
4  * Created: Thu May 08 13:53:00 2008
5  * Copyright 2008 Christof Rath <c.rath@student.tugraz.at>
6  *
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version. A runtime exception applies to
13  * this software (see LICENSE.GPL_WRE file mentioned below for details).
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
21  */
22 
23 #include <fvmodels/camera/ccd_calibration.h>
24 
25 #include <cmath>
26 
27 namespace firevision {
28 #if 0 /* just to make Emacs auto-indent happy */
29 }
30 #endif
31 
32 /** @class CCDCalibration <fvmodels/camera/ccd_calibration.h>
33  * A Calibration matrix for a ccd camera
34  * @author Christof Rath
35  */
36 
37 /**Constructor.
38  * @param ax is the scale factor in the x-coordinate direction
39  * @param ay is the scale factor in the y-coordinate direction
40  * @param x0 is the x-coordinate of the principal point
41  * @param y0 is the y-coordinate of the principal point
42  */
43 CCDCalibration::CCDCalibration(float ax, float ay, float x0, float y0):
44  Calibration()
45 {
46  Matrix k(3, 3);
47  k(0, 0) = ax;
48  k(1, 1) = ay;
49  k(2, 2) = 1.f;
50  k(0, 2) = x0;
51  k(1, 2) = y0;
52 
53  K(k);
54 }
55 
56 /**
57  * Constructor.
58  * @param hor_fov horizontal field of view [rad]
59  * @param img_width width of the image [px]
60  * @param img_height height of the image [px]
61  */
62 CCDCalibration::CCDCalibration(float hor_fov, unsigned int img_width, unsigned int img_height):
63  Calibration()
64 {
65  float w = img_width;
66  float h = img_height;
67  float ver_fov = hor_fov * h / w;
68 
69  Matrix k(3, 3);
70  k(0, 0) = w / (2.f * tanf(hor_fov / 2.f));
71  k(1, 1) = h / (2.f * tanf(ver_fov / 2.f));
72  k(2, 2) = 1.f;
73  k(0, 2) = w / 2.f;
74  k(1, 2) = h / 2.f;
75 
76  K(k);
77 }
78 
79 /** Copy constructor.
80  * @param cp the CCDCalibration to copy
81  */
83  Calibration()
84 {
85  K(cp.K());
86 }
87 
88 /** Destructor.
89  */
91 {
92 }
93 
94 } // end namespace firevision