ccd_calibration.cpp
00001 /*************************************************************************** 00002 * ccd_calibration.cpp - Class defining a ccd camera calibration matrix K 00003 * 00004 * Generated: Thu May 8 13:53 2008 00005 * Copyright 2008 Christof Rath <c.rath@student.tugraz.at> 00006 * 00007 ****************************************************************************/ 00008 00009 /* This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. A runtime exception applies to 00013 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00021 */ 00022 00023 00024 #include "ccd_calibration.h" 00025 #include <cmath> 00026 00027 /** @class CCDCalibration <models/camera/ccd_calibration.h> 00028 * A Calibration matrix for a ccd camera 00029 * @author Christof Rath 00030 */ 00031 00032 /**Constructor. 00033 * @param ax is the scale factor in the x-coordinate direction 00034 * @param ay is the scale factor in the y-coordinate direction 00035 * @param x0 is the x-coordinate of the principal point 00036 * @param y0 is the y-coordinate of the principal point 00037 */ 00038 CCDCalibration::CCDCalibration(float ax, float ay, float x0, float y0): 00039 Calibration() 00040 { 00041 Matrix k(3, 3); 00042 k(0, 0) = ax; 00043 k(1, 1) = ay; 00044 k(2, 2) = 1.f; 00045 k(0, 2) = x0; 00046 k(1, 2) = y0; 00047 00048 K(k); 00049 } 00050 00051 /** 00052 * Constructor. 00053 * @param hor_fov horizontal field of view [rad] 00054 * @param img_width width of the image [px] 00055 * @param img_height height of the image [px] 00056 */ 00057 CCDCalibration::CCDCalibration(float hor_fov, unsigned int img_width, unsigned int img_height): 00058 Calibration() 00059 { 00060 float w = img_width; 00061 float h = img_height; 00062 float ver_fov = hor_fov * h / w; 00063 00064 Matrix k(3, 3); 00065 k(0, 0) = w / (2.f * tanf(hor_fov / 2.f)); 00066 k(1, 1) = h / (2.f * tanf(ver_fov / 2.f)); 00067 k(2, 2) = 1.f; 00068 k(0, 2) = w / 2.f; 00069 k(1, 2) = h / 2.f; 00070 00071 K(k); 00072 } 00073 00074 /** Copy constructor. 00075 * @param cp the CCDCalibration to copy 00076 */ 00077 CCDCalibration::CCDCalibration(const CCDCalibration& cp): 00078 Calibration() 00079 { 00080 K(cp.K()); 00081 } 00082 00083 /** Destructor. 00084 */ 00085 CCDCalibration::~CCDCalibration() 00086 { 00087 }

