00001 /******************************************************************************* 00002 * ImageGrabber.h 00003 * 00004 * (C) 2006 AG Aktives Sehen <agas@uni-koblenz.de> 00005 * Universitaet Koblenz-Landau 00006 * 00007 * Additional information: 00008 * $Id: ImageGrabber.h 44313 2011-04-06 22:46:28Z agas $ 00009 ******************************************************************************/ 00010 00011 #ifndef ImageGrabber_H 00012 #define ImageGrabber_H 00013 00014 //#include "Camera.h" 00015 //#include "../../Workers/Puma2/ColorImageUV8.h" 00016 00017 //#include "GrabbingDevice.h" 00018 #include "../../Workers/Puma2/ColorImageRGB8.h" 00019 #include "../../Workers/Puma2/GrayLevelImage8.h" 00020 00021 #include "../../Workers/ImageSources/ImageSources.h" 00022 00023 //#include <map> 00024 //#include <string> 00025 00030 class ImageGrabber 00031 { 00032 public: 00033 00035 enum ColorFormat{ 00036 UYVY8=0, //Pixel format of YUV 4:2:2 00037 RGB8=1, 00038 GRAY8=2, 00039 Y8UV8=3 //Y and UV as separate images 00040 }; 00041 00043 enum ImageQuality{ 00044 LOW=0, 00045 HIGH=1 00046 }; 00047 00049 enum ScaleFactor{ 00050 FULL=1, 00051 HALF=2, 00052 QUARTER=4 00053 }; 00054 00055 ImageGrabber() {}; 00056 00057 // /** 00058 // * @brief The constructor 00059 // * @param parentName Used as main name for the timers */ 00060 ImageGrabber(std::string parentName); 00061 00062 // /** The destructor. */ 00063 virtual ~ImageGrabber(); 00064 00065 // /** 00066 // * @brief Assigns an ID to a camera, initializes it and starts grabbing process 00067 // * @param sourceId ID to be assigned to the cameras 00068 // * @param cam contains description & parameters of the camera 00069 // * @return false if an error has occured 00070 // */ 00071 // bool setCamera( ImageSources::SourceId sourceId, Camera cam ); 00072 00073 // /** 00074 // * @brief Grabs a single RGB image from a camera. 00075 // * @param sourceId ID of the camera to be used 00076 // * @param image target image 00077 // * @return true if grabbing was successfull 00078 // * false otherwise 00079 // */ 00080 // bool grabImageRgb( ImageSources::SourceId sourceId, ScaleFactor scaling, ImageQuality quality, puma2::ColorImageRGB8 &image ); 00081 00082 // /** 00083 // * @brief Grabs a single image from a YUV422 camera and stores it in a GrayLevelmage8 and a ColorImageUV8 00084 // * @param sourceId ID of the camera to be used 00085 // * @param grayImage,uvImage target images 00086 // * @return true if grabbing was successfull 00087 // * false otherwise 00088 // */ 00089 // bool grabImageYuv( ImageSources::SourceId sourceId, ScaleFactor scaling, ImageQuality quality, 00090 // puma2::GrayLevelImage8 &grayImage, puma2::ColorImageUV8 &uvImage ); 00091 00092 // /** 00093 // * @brief Does whitebalancing. 00094 // * @return True if whitebalancing is done without errors. 00095 // */ 00096 // bool doWhiteBalance( ImageSources::SourceId sourceId ); 00097 00098 // /** 00099 // * @brief Sets camera proptery either absolute or relative. 00100 // * @return True if setting of camera proptery is done without errors. 00101 // */ 00102 // bool setCameraProperty(ImageSources::SourceId sourceId, string param, double value, bool isAbsolute=true); 00103 00104 // /** 00105 // * @brief Gets camera proptery 00106 // * @return value of camera property 00107 // */ 00108 // double getCameraProperty(ImageSources::SourceId sourceId, string param); 00109 00110 // /** 00111 // * @brief Sets camera zoom proptery either absolute or relative wth zoomfactorvalues in one dimension. 00112 // * @brief Needed to convert zoomvalues to zoomfactors. 00113 // * @return True if setting of camera proptery is done without errors. 00114 // */ 00115 // bool setCameraZoomProperty(ImageSources::SourceId sourceId, float factor, bool isAbsolute=true); 00116 00117 // /** 00118 // * @brief Clean the buffer queue. Should be called at least as often as the highest frame rate 00119 // * @brief of all cameras. 00120 // */ 00121 // void cleanBuffers(); 00122 00123 // /** 00124 // * @brief Calculate viewangle from zoomvalue (range: 40-1432) 00125 // * @brief CAUTION!: Due to missing real viewangle the values might be wrong. Calibration PI * thumb (5 mesasures, cubic polynom). 00126 // */ 00127 // static double zoomToAngle(double zoom); 00128 00129 // /** 00130 // * @brief Calculate zoomvalue (range: 40-1432) from viewangle 00131 // * @brief CAUTION!: inverse function to zoomToAngle (see description) 00132 // */ 00133 // static double angleToZoom(double angle); 00134 00135 // /* 00136 // double factorToAngle(double factor); 00137 00138 // double angleToFactor(double arc);*/ 00139 00140 // void applySobel(puma2::GrayLevelImage8* image); 00141 00142 // long measureSharpness(puma2::GrayLevelImage8* image); 00143 00144 // private: 00145 00146 // /** 00147 // * @brief Initializes a camera. 00148 // * @return True if initialization was successful. 00149 // */ 00150 // bool initCamera( ImageSources::SourceId sourceId ); 00151 00152 // /** 00153 // * @brief Stops a camera. 00154 // * @return True if camera could be stopped without errors. 00155 // */ 00156 // bool stopCamera( ImageSources::SourceId sourceId ); 00157 00158 // /** @brief checks if the given camera is available */ 00159 // bool checkCamera( ImageSources::SourceId sourceId ); 00160 00161 // /** @brief grab raw YUV data */ 00162 // bool grabDataYuv( ImageSources::SourceId sourceId, unsigned char* buffer ); 00163 00164 // /** @brief Convert & scale raw YUV422 data 00165 // * @note In YUV422, the U and V channel have only half the horizontal resolution 00166 // * Data format: UY,VY,UY,VY,.. 00167 // */ 00168 // bool yuv422To444( ImageQuality quality, int width, int height, ScaleFactor scaling, unsigned char* buffer, 00169 // puma2::GrayLevelImage8 &yImage, puma2::ColorImageUV8 &uvImage); 00170 00171 // /** @brief maps an id to a camera / its state / the associated grabbing device */ 00172 // map<ImageSources::SourceId,Camera> m_Cameras; 00173 // map<ImageSources::SourceId,bool> m_Initialized; 00174 // map<ImageSources::SourceId,puma2::GrabbingDevice*> m_GrabbingDevices; 00175 00176 // /** @brief maps format description strings to format IDs */ 00177 // map<std::string,ColorFormat> m_ColorFormatId; 00178 00179 00180 }; 00181 00182 #endif