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: Virtual color camera representation. 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: Jan 2009 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 00054 00059 00060 #ifndef __IPA_VIRTUALCOLORCAM_H__ 00061 #define __IPA_VIRTUALCOLORCAM_H__ 00062 00063 #ifdef __LINUX__ 00064 #include "cob_camera_sensors/AbstractColorCamera.h" 00065 #else 00066 #include "cob_driver/cob_camera_sensors/common/include/cob_camera_sensors/AbstractColorCamera.h" 00067 #endif 00068 00069 #include <cstdlib> 00070 #include <boost/filesystem.hpp> 00071 namespace fs = boost::filesystem; 00072 using namespace std; 00073 00074 #ifdef SWIG 00075 %module Sensors 00076 %include "Source/Vision/CameraSensors/AbstractColorCamera.h" 00077 00078 %{ 00079 #include "VirtualColorCam.h" 00080 %} 00081 #endif 00082 00083 namespace ipa_CameraSensors { 00088 class __DLL_LIBCAMERASENSORS__ VirtualColorCam : public AbstractColorCamera 00089 { 00090 private: 00091 int m_ImageWidth; 00092 int m_ImageHeight; 00093 00094 std::string m_CameraDataDirectory; 00095 int m_CameraIndex; 00096 00097 std::vector<std::string> m_ColorImageFileNames; 00098 00099 unsigned int m_ImageCounter; 00100 00106 unsigned long LoadParameters(const char* filename, int cameraIndex); 00107 00108 unsigned long SetParameters(){return RET_OK;}; 00109 00110 public: 00111 00112 VirtualColorCam (); 00113 ~VirtualColorCam (); 00114 00115 //******************************************************************************* 00116 // AbstractColorCamera interface implementation 00117 //******************************************************************************* 00118 00119 unsigned long Init(std::string directory, int cameraIndex = 0); 00120 00121 unsigned long Open(); 00122 unsigned long Close(); 00123 00124 unsigned long GetColorImage(char* colorImageData, bool getLatestFrame); 00125 unsigned long GetColorImage(cv::Mat* image, bool getLatestFrame); 00126 00127 unsigned long SaveParameters(const char* filename); //speichert die Parameter in das File 00128 unsigned long SetProperty(t_cameraProperty* cameraProperty); 00129 unsigned long SetPropertyDefaults(); 00130 unsigned long GetProperty(t_cameraProperty* cameraProperty); 00131 unsigned long PrintCameraInformation(); 00132 unsigned long TestCamera(const char* filename); 00133 00134 //******************************************************************************* 00135 // Camera specific functions 00136 //******************************************************************************* 00137 00140 int GetNumberOfImages(); 00141 00146 unsigned long SetPathToImages(std::string path); 00147 00148 }; 00149 00152 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr CreateColorCamera_VirtualCam(); 00153 00154 } // end namespace ipa_CameraSensors 00155 00156 #endif //__IPA_VIRTUALCOLORCAM_H__ 00157 00158