camera.cpp
00001 00002 /*************************************************************************** 00003 * camera.cpp - Abstract class defining a camera 00004 * 00005 * Created: Wed Jan 17 14:48:17 2007 00006 * Copyright 2005-2009 Tim Niemueller [www.niemueller.de] 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 <cams/camera.h> 00025 00026 #include <core/exception.h> 00027 #include <core/exceptions/software.h> 00028 00029 /** @class Camera cams/camera.h 00030 * Camera interface for image aquiring devices in FireVision. 00031 * 00032 * In general cameras shall initiate a continuous flow of images and shall 00033 * be optimized for real-time image processing (25 Hz). 00034 * 00035 * @fn void Camera::open() = 0 00036 * Open the camera. 00037 * The camera is opened, but image transfer not yet started. This can be used 00038 * to detect general problems with the camera while delaying the real transfer 00039 * startup until it is needed. 00040 * 00041 * @fn void Camera::start() 00042 * Start image transfer from the camera. 00043 * For many cameras opening the camera and starting transmission of images are 00044 * two tasks. This method will simply initiate the transfer after the camera 00045 * as been opened. And exception shall be thrown if the camera has not been 00046 * opened. 00047 * 00048 * @fn void Camera::stop() 00049 * Stop image transfer from the camera. 00050 * This will stop the image transfer initiated with start(). This can be used 00051 * to start and stop the image transfer at will without opening and closing 00052 * operations inbetween. 00053 * 00054 * @fn void Camera::close() 00055 * Close camera. 00056 * This closes the camera device. The camera must have been stopped before 00057 * calling close(). 00058 * 00059 * @fn void Camera::capture() 00060 * Capture an image. 00061 * Although cameras shall operate with a continuous image flow where possible 00062 * sometimes capturing an image means copying a buffer or advancing a buffer 00063 * list pointer. This shall be done in this method. For a camera-using 00064 * application it is mandatory to call capture() just before accessing the 00065 * image buffer. 00066 * 00067 * @fn void Camera::flush() 00068 * Flush image queue. 00069 * Some cameras may have an image buffer queue. With this it can happen that 00070 * if the processing of an image took longer than desired it is needed to flush 00071 * this buffer queue. 00072 * 00073 * @fn bool Camera::ready() 00074 * Camera is ready for taking pictures. 00075 * The camera has been opened and started correctly and may now provide images. 00076 * @return true, if the camera is ready, false otherwise 00077 * 00078 * @fn void Camera::print_info() 00079 * Print out camera information. 00080 * Shall print out camera information and current setup information on stdout. 00081 * 00082 * @fn unsigned char * Camera::buffer() 00083 * Get access to current image buffer. 00084 * This will return a pointer to the current buffer. The buffer contains an 00085 * image of the given colorspace, width and height. 00086 * @return pointer to image buffer 00087 * 00088 * @fn void Camera::dispose_buffer() 00089 * Dispose current buffer. 00090 * Some cameras need disposal of the current buffer (for example to free space 00091 * in a queue to retrieve the next image). This is done with this method. It 00092 * has to be called after all work has been done on the image as desired. After 00093 * dispose_buffer() has been called no further access may happen to the image 00094 * buffer or undesired behavior may happen. 00095 * 00096 * @fn unsigned int Camera::buffer_size() 00097 * Size of buffer. 00098 * Gets the size in bytes of the buffer returned by buffer(). 00099 * @return size of buffer in bytes 00100 * 00101 * @fn colorspace_t Camera::colorspace() 00102 * Colorspace of returned image. 00103 * @return colorspace of image returned by buffer() 00104 * 00105 * @fn unsigned int Camera::pixel_width() 00106 * Width of image in pixels. 00107 * @return width of image in pixels 00108 * 00109 * @fn unsigned int Camera::pixel_height() 00110 * Height of image in pixels. 00111 * @return height of image in pixels 00112 * 00113 * @fn void Camera::set_image_number(unsigned int n) 00114 * Set image number to retrieve. 00115 * If a camera is able to retrieve several images this method can be used to 00116 * select the image to be retrieved with the next call to capture(). 00117 * @param n image number to set 00118 * 00119 */ 00120 00121 /** Virtual empty destructor. */ 00122 Camera::~Camera() 00123 { 00124 } 00125 00126 /** Get the Time of the last successfully captured image. 00127 * Returns a Time representing the time when the last image was captured 00128 * successfully. Note that calling this function is only valid after capture() 00129 * and before dispose_buffer() has been called -- it is only valid when an image 00130 * is currently available. 00131 * @return Time of the currently processed image. The pointer shall be valid at 00132 * least until the next call to dispose_buffer(). 00133 * @throw NotImplementedException thrown if Camera does not support time stamping 00134 */ 00135 fawkes::Time * 00136 Camera::capture_time() 00137 { 00138 throw fawkes::NotImplementedException("Timestamping not supported by this camera"); 00139 }

