Fawkes API
Fawkes Development Version
|
00001 /*************************************************************************** 00002 * calibration.cpp - Abstract class defining a camera calibration matrix K 00003 * for a finite camera 00004 * 00005 * Created: Thu May 08 13:24:00 2008 00006 * Copyright 2008 Christof Rath <c.rath@student.tugraz.at> 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <models/camera/calibration.h> 00025 #include <iostream> 00026 #include <core/exceptions/software.h> 00027 00028 using namespace fawkes; 00029 00030 namespace firevision { 00031 #if 0 /* just to make Emacs auto-indent happy */ 00032 } 00033 #endif 00034 00035 /** @class Calibration <models/camera/calibration.h> 00036 * A Calibration matrix for a finite camera. 00037 * 00038 * @author Christof Rath 00039 */ 00040 00041 /** Hidden default constructor. 00042 */ 00043 Calibration::Calibration(): Matrix(3, 3) 00044 { 00045 id(); 00046 } 00047 00048 /** Constructor. 00049 * @param k 3x3 Calibration matrix of the camera 00050 */ 00051 Calibration::Calibration(const fawkes::Matrix& k): Matrix(3, 3) 00052 { 00053 K(k); 00054 } 00055 00056 /** Copy Constructor. 00057 * @param cal the Calibration to copy 00058 */ 00059 Calibration::Calibration(const Calibration& cal): Matrix(3, 3) 00060 { 00061 K(cal.K()); 00062 } 00063 00064 /** Destructor. 00065 */ 00066 Calibration::~Calibration() 00067 { 00068 } 00069 00070 /** Calibration getter. 00071 * @return The calibration matrix 00072 */ 00073 Matrix 00074 Calibration::K() const 00075 { 00076 return get_submatrix(0, 0, 3, 3); 00077 } 00078 00079 /** Sets the calibration matrix. 00080 * The matrix k has a size 3x3. The elements (row by row): 00081 * scale factor in x-direction, skew, x-coordinate of the principal point 00082 * 0, scale factor in y-direction, y-coordinate of the principal point 00083 * 0, 0, 1 00084 * @param k the calibration matrix 00085 * @return reference to this instance 00086 */ 00087 Calibration& 00088 Calibration::K(const fawkes::Matrix& k) 00089 { 00090 unsigned int i,j; 00091 k.size(i, j); 00092 00093 if (i != j || i != 3) 00094 throw IllegalArgumentException("The calibration matrix has to be 3 by 3"); 00095 00096 id(); 00097 overlay (0, 0, k); 00098 return *this; 00099 } 00100 00101 } // end namespace firevision