color.cpp

00001
00002 /***************************************************************************
00003  *  color.cpp - Abstract class defining a camera color controller
00004  *
00005  *  Created: Wed Apr 22 11:19:04 2009
00006  *  Copyright  2009      Tobias Kellner
00007  *             2005-2009 Tim Niemueller [www.niemueller.de]
00008  *
00009  ****************************************************************************/
00010
00011
00012 /*  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version. A runtime exception applies to
00016  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU Library General Public License for more details.
00022  *
00023  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00024  */
00025
00026 #include <cams/control/color.h>
00027 #include <core/exceptions/software.h>
00028 
00029 /** @class CameraControlColor <cams/control/color.h>
00030  * Camera color control interface.
00031  * Some cameras feature adjustable color controls
00032  * like white balance, brightness etc.
00033  * In general methods might throw an NotImplementedException if a particular
00034  * method if not available.
00035  *
00036  * This interface shall be implemented by such cameras.
00037  *
00038  * @author Tobias Kellner
00039  * @author Tim Niemueller
00040  *
00041  *
00042  * @fn bool CameraControlColor::auto_gain() = 0
00043  * Return whether auto gain is enabled.
00044  * @return true if auto gain is enabled
00045  *
00046  * @fn void CameraControlColor::set_auto_gain(bool enabled) = 0
00047  * Enable/disable auto gain.
00048  * @param enabled whether auto gain should be enabled
00049  *
00050  * @fn bool CameraControlColor::auto_white_balance() = 0
00051  * Return whether auto white balance is enabled.
00052  * @return true if auto white balance is enabled
00053  *
00054  * @fn void CameraControlColor::set_auto_white_balance(bool enabled) = 0
00055  * Enable/disable auto white balance.
00056  * @param enabled whether auto white balance should be enabled
00057  *
00058  * @fn bool CameraControlColor::auto_exposure() = 0
00059  * Return whether auto exposure is enabled.
00060  * @return true if auto exposure is enabled
00061  *
00062  * @fn void CameraControlColor::set_auto_exposure(bool enabled) = 0
00063  * Enable/disable auto exposure.
00064  * @param enabled whether auto exposure should be enabled
00065  *
00066  * @fn int CameraControlColor::red_balance() = 0
00067  * Get current red balance.
00068  * @return current red balance value
00069  *
00070  * @fn int CameraControlColor::set_red_balance(int red_balance) = 0
00071  * Set red balance.
00072  * @param red_balance new red balance
00073  *
00074  * @fn int CameraControlColor::blue_balance() = 0
00075  * Get current blue balance.
00076  * @return current blue balance value
00077  *
00078  * @fn void CameraControlColor::set_blue_balance(int blue_balance) = 0
00079  * Set blue balance.
00080  * @param blue_balance new blue balance
00081  *
00082  * @fn int CameraControlColor::u_balance() = 0
00083  * Get current u balance.
00084  * @return current u balance value
00085  *
00086  * @fn void CameraControlColor::set_u_balance(int u_balance) = 0
00087  * Set u balance.
00088  * @param u_balance new u balance
00089  *
00090  * @fn int CameraControlColor::v_balance() = 0
00091  * Get current v balance.
00092  * @return current v balance value
00093  *
00094  * @fn void CameraControlColor::set_v_balance(int v_balance) = 0
00095  * Set v balance.
00096  * @param v_balance new v balance
00097  *
00098  * @fn unsigned int CameraControlColor::brightness() = 0
00099  * Get current brightness.
00100  * @return current brightness value
00101  *
00102  * @fn void CameraControlColor::set_brightness(unsigned int brightness) = 0
00103  * Set new brightness.
00104  * @param brightness new brightness
00105  *
00106  * @fn unsigned int CameraControlColor::contrast() = 0
00107  * Get current contrast.
00108  * @return current contrast value
00109  *
00110  * @fn void CameraControlColor::set_contrast(unsigned int contrast) = 0
00111  * Set new contrast.
00112  * @param contrast new contrast
00113  *
00114  * @fn unsigned int CameraControlColor::saturation() = 0
00115  * Get current saturation.
00116  * @return current saturation value
00117  *
00118  * @fn void CameraControlColor::set_saturation(unsigned int saturation) = 0
00119  * Set new saturation.
00120  * @param saturation new saturation
00121  *
00122  * @fn int CameraControlColor::hue() = 0
00123  * Get current hue.
00124  * @return current hue value
00125  *
00126  * @fn void CameraControlColor::set_hue(int hue) = 0
00127  * Set new hue.
00128  * @param hue new hue
00129  *
00130  * @fn unsigned int CameraControlColor::exposure() = 0
00131  * Get current exposure
00132  * @return current exposure value
00133  *
00134  * @fn void CameraControlColor::set_exposure(unsigned int exposure) = 0
00135  * Set new exposure.
00136  * @param exposure new exposure
00137  *
00138  * @fn unsigned int CameraControlColor::gain() = 0
00139  * Get current gain.
00140  * @return current gain value
00141  *
00142  * @fn void CameraControlColor::set_gain(unsigned int gain) = 0
00143  * Set new gain.
00144  * @param gain new gain
00145  */
00146
00147 using fawkes::NotImplementedException;
00148 
00149 /** Empty virtual destructor. */
00150 CameraControlColor::~CameraControlColor()
00151 {
00152 }
00153
00154 
00155 /** Enable/disable all automatic settings.
00156  * Most of the time, you'll want to disable all of them.
00157  * @param enabled whether the automatic settings should be enabled or disabled
00158  */
00159 void
00160 CameraControlColor::set_auto_all(bool enabled)
00161 {
00162   try {
00163     set_auto_gain(enabled);
00164   } catch (NotImplementedException) {}
00165   try {
00166     set_auto_white_balance(enabled);
00167   } catch (NotImplementedException) {}
00168   try {
00169     set_auto_exposure(enabled);
00170   } catch (NotImplementedException) {}
00171 }