00001 /* 00002 * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA) 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 00022 00023 #ifndef __IPA_ABSTRACTCOLORCAMERA_H__ 00024 #define __IPA_ABSTRACTCOLORCAMERA_H__ 00025 00026 #include "StdAfx.h" 00027 00028 #ifdef __LINUX__ 00029 #include "cob_vision_utils/CameraSensorDefines.h" 00030 #include "cob_vision_utils/CameraSensorTypes.h" 00031 #else 00032 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorDefines.h" 00033 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorTypes.h" 00034 #endif 00035 00036 #include <boost/shared_ptr.hpp> 00037 #include <sstream> 00038 #include <opencv/cv.h> 00039 00040 namespace ipa_CameraSensors { 00041 00043 class AbstractColorCamera; 00044 typedef boost::shared_ptr<AbstractColorCamera> AbstractColorCameraPtr; 00045 00050 class __DLL_LIBCAMERASENSORS__ AbstractColorCamera 00051 { 00052 public: 00053 00056 struct t_ColorCameraParameters 00057 { 00058 ipa_CameraSensors::t_cameraRole m_CameraRole; 00059 std::stringstream m_VideoFormat; 00060 std::stringstream m_VideoMode; 00061 std::stringstream m_ColorMode; 00062 std::stringstream m_IsoSpeed; 00063 std::stringstream m_FrameRate; 00064 std::stringstream m_Shutter; 00065 std::stringstream m_WhiteBalanceU; 00066 std::stringstream m_WhiteBalanceV; 00067 std::stringstream m_Hue; 00068 std::stringstream m_Saturation; 00069 std::stringstream m_Gamma; 00070 std::stringstream m_ExposureTime; 00071 std::stringstream m_Gain; 00072 std::stringstream m_Brightness; 00073 std::stringstream m_ImageWidth; 00074 std::stringstream m_ImageHeight; 00075 std::stringstream m_Interface; 00076 std::stringstream m_IP; 00077 }; 00078 00086 virtual unsigned long Init(std::string directory, int cameraIndex = 0) =0; 00087 00090 virtual bool isInitialized() {return m_initialized;} 00091 00094 virtual bool isOpen() {return m_open;} 00095 00100 virtual unsigned long Open() =0; 00101 00104 virtual unsigned long Close() =0; //Save intrinsic params back to File 00105 00111 unsigned long GetColorImage(char* colorImageData, bool getLatestFrame=true) {return RET_FAILED;} 00112 00120 virtual unsigned long GetColorImage(cv::Mat* colorImage, bool getLatestFrame=true)=0; 00121 00124 virtual t_cameraType GetCameraType(); 00125 00130 virtual unsigned long SetProperty(t_cameraProperty* cameraProperty) =0; 00131 00134 virtual unsigned long SetPropertyDefaults() =0; 00135 00140 virtual unsigned long GetProperty(t_cameraProperty* cameraProperty) =0; 00141 00145 virtual unsigned long PrintCameraInformation() =0; 00146 00150 virtual unsigned long SaveParameters(const char* filename)=0; 00151 00157 virtual unsigned long TestCamera(const char* filename); 00158 00161 virtual int GetNumberOfImages() {return std::numeric_limits<int>::max();}; 00162 00167 virtual unsigned long SetPathToImages(std::string path) {return RET_OK;}; 00168 00170 virtual ~AbstractColorCamera(); 00171 00172 protected: 00173 00174 bool m_initialized; 00175 bool m_open; 00176 00177 t_ColorCameraParameters m_ColorCameraParameters; 00178 00179 t_cameraType m_CameraType; 00180 00181 unsigned int m_BufferSize; 00182 private: 00183 00188 virtual unsigned long LoadParameters(const char* filename, int cameraIndex)=0; 00189 00192 virtual unsigned long SetParameters()=0; 00193 00194 }; 00195 00198 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_VirtualCam(); 00199 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_ICCam(); 00200 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_AxisCam(); 00201 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_AVTPikeCam(); 00202 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_OpenCVCamera(); 00203 00204 00205 } // end namespace 00206 #endif // __IPA_ABSTRACTCOLORCAMERA_H__