00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2010 00004 * 00005 * Fraunhofer Institute for Manufacturing Engineering 00006 * and Automation (IPA) 00007 * 00008 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: care-o-bot 00011 * ROS stack name: cob_driver 00012 * ROS package name: cob_camera_sensors 00013 * Description: Abstract interface for color cameras. 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: Jan Fischer, email:jan.fischer@ipa.fhg.de 00018 * Supervised by: Jan Fischer, email:jan.fischer@ipa.fhg.de 00019 * 00020 * Date of creation: May 2008 00021 * ToDo: 00022 * 00023 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00024 * 00025 * Redistribution and use in source and binary forms, with or without 00026 * modification, are permitted provided that the following conditions are met: 00027 * 00028 * * Redistributions of source code must retain the above copyright 00029 * notice, this list of conditions and the following disclaimer. 00030 * * Redistributions in binary form must reproduce the above copyright 00031 * notice, this list of conditions and the following disclaimer in the 00032 * documentation and/or other materials provided with the distribution. 00033 * * Neither the name of the Fraunhofer Institute for Manufacturing 00034 * Engineering and Automation (IPA) nor the names of its 00035 * contributors may be used to endorse or promote products derived from 00036 * this software without specific prior written permission. 00037 * 00038 * This program is free software: you can redistribute it and/or modify 00039 * it under the terms of the GNU Lesser General Public License LGPL as 00040 * published by the Free Software Foundation, either version 3 of the 00041 * License, or (at your option) any later version. 00042 * 00043 * This program is distributed in the hope that it will be useful, 00044 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00045 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00046 * GNU Lesser General Public License LGPL for more details. 00047 * 00048 * You should have received a copy of the GNU Lesser General Public 00049 * License LGPL along with this program. 00050 * If not, see <http://www.gnu.org/licenses/>. 00051 * 00052 ****************************************************************/ 00053 00058 00059 #ifndef __IPA_ABSTRACTCOLORCAMERA_H__ 00060 #define __IPA_ABSTRACTCOLORCAMERA_H__ 00061 00062 #include "StdAfx.h" 00063 00064 #ifdef __LINUX__ 00065 #include "cob_vision_utils/CameraSensorDefines.h" 00066 #include "cob_vision_utils/CameraSensorTypes.h" 00067 #else 00068 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorDefines.h" 00069 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorTypes.h" 00070 #endif 00071 00072 #include <boost/shared_ptr.hpp> 00073 #include <sstream> 00074 #include <opencv/cv.h> 00075 00076 namespace ipa_CameraSensors { 00077 00079 class AbstractColorCamera; 00080 typedef boost::shared_ptr<AbstractColorCamera> AbstractColorCameraPtr; 00081 00086 class __DLL_LIBCAMERASENSORS__ AbstractColorCamera 00087 { 00088 public: 00089 00092 struct t_ColorCameraParameters 00093 { 00094 ipa_CameraSensors::t_cameraRole m_CameraRole; 00095 std::stringstream m_VideoFormat; 00096 std::stringstream m_VideoMode; 00097 std::stringstream m_ColorMode; 00098 std::stringstream m_IsoSpeed; 00099 std::stringstream m_FrameRate; 00100 std::stringstream m_Shutter; 00101 std::stringstream m_WhiteBalanceU; 00102 std::stringstream m_WhiteBalanceV; 00103 std::stringstream m_Hue; 00104 std::stringstream m_Saturation; 00105 std::stringstream m_Gamma; 00106 std::stringstream m_ExposureTime; 00107 std::stringstream m_Gain; 00108 std::stringstream m_Brightness; 00109 std::stringstream m_ImageWidth; 00110 std::stringstream m_ImageHeight; 00111 std::stringstream m_Interface; 00112 std::stringstream m_IP; 00113 }; 00114 00122 virtual unsigned long Init(std::string directory, int cameraIndex = 0) =0; 00123 00126 virtual bool isInitialized() {return m_initialized;} 00127 00130 virtual bool isOpen() {return m_open;} 00131 00136 virtual unsigned long Open() =0; 00137 00140 virtual unsigned long Close() =0; //Save intrinsic params back to File 00141 00147 unsigned long GetColorImage(char* colorImageData, bool getLatestFrame=true) {return RET_FAILED;} 00148 00156 virtual unsigned long GetColorImage(cv::Mat* colorImage, bool getLatestFrame=true)=0; 00157 00160 virtual t_cameraType GetCameraType(); 00161 00166 virtual unsigned long SetProperty(t_cameraProperty* cameraProperty) =0; 00167 00170 virtual unsigned long SetPropertyDefaults() =0; 00171 00176 virtual unsigned long GetProperty(t_cameraProperty* cameraProperty) =0; 00177 00181 virtual unsigned long PrintCameraInformation() =0; 00182 00186 virtual unsigned long SaveParameters(const char* filename)=0; 00187 00193 virtual unsigned long TestCamera(const char* filename); 00194 00197 virtual int GetNumberOfImages() {return std::numeric_limits<int>::max();}; 00198 00203 virtual unsigned long SetPathToImages(std::string path) {return RET_OK;}; 00204 00206 virtual ~AbstractColorCamera(); 00207 00208 protected: 00209 00210 bool m_initialized; 00211 bool m_open; 00212 00213 t_ColorCameraParameters m_ColorCameraParameters; 00214 00215 t_cameraType m_CameraType; 00216 00217 unsigned int m_BufferSize; 00218 private: 00219 00224 virtual unsigned long LoadParameters(const char* filename, int cameraIndex)=0; 00225 00228 virtual unsigned long SetParameters()=0; 00229 00230 }; 00231 00234 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_VirtualCam(); 00235 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_ICCam(); 00236 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_AxisCam(); 00237 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_AVTPikeCam(); 00238 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_OpenCVCamera(); 00239 00240 00241 } // end namespace 00242 #endif // __IPA_ABSTRACTCOLORCAMERA_H__