$search
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: 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: Mai 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 00054 #include "../include/cob_camera_sensors/StdAfx.h" 00055 00056 #ifdef __LINUX__ 00057 #include "cob_camera_sensors/AbstractColorCamera.h" 00058 #else 00059 #include "cob_driver/cob_camera_sensors/common/include/cob_camera_sensors/AbstractColorCamera.h" 00060 #endif 00061 00062 #include <iostream> 00063 00064 using namespace ipa_CameraSensors; 00065 00066 AbstractColorCamera::~AbstractColorCamera() 00067 { 00068 } 00069 00070 t_cameraType AbstractColorCamera::GetCameraType() 00071 { 00072 return m_CameraType; 00073 } 00074 00075 unsigned long AbstractColorCamera::TestCamera(const char* filename) 00076 { 00077 std::cout << "AbstractColorCamera::TestCamera: Testing camera interface class AbstractColorCamera..." << std::endl; 00078 std::cout << std::endl; 00079 if (!isInitialized()) 00080 { 00081 std::cout << "AbstractColorCamera::TestCamera: Initializing camera device..." << std::endl; 00082 if (Init(filename) & (RET_FAILED | RET_FUNCTION_NOT_IMPLEMENTED)) 00083 { 00084 std::cout << "AbstractColorCamera::TestCamera: Initializing camera device... FAILED" << std::endl; 00085 return (RET_FAILED | RET_INIT_CAMERA_FAILED); 00086 } 00087 std::cout << "AbstractColorCamera::TestCamera: Initializing camera device... OK" << std::endl; 00088 } 00089 std::cout << std::endl; 00090 00091 if (!isOpen()) 00092 { 00093 std::cout << "AbstractColorCamera::TestCamera: Opening camera device..." << std::endl; 00094 if (Open() & (RET_FAILED | RET_FUNCTION_NOT_IMPLEMENTED)) 00095 { 00096 std::cout << "AbstractColorCamera::TestCamera: Opening camera device... FAILED" << std::endl; 00097 return (RET_FAILED | RET_OPEN_CAMERA_FAILED); 00098 } 00099 std::cout << "AbstractColorCamera::TestCamera: Opening camera device... OK" << std::endl; 00100 } 00101 std::cout << std::endl; 00102 00103 std::cout << "AbstractColorCamera::TestCamera: Displaying camera information..." << std::endl; 00104 unsigned long ret = PrintCameraInformation(); 00105 if (ret & RET_FAILED) 00106 { 00107 std::cout << "AbstractColorCamera::TestCamera: Displaying camera information... FAILED." << std::endl; 00108 return (RET_FAILED | RET_OPEN_CAMERA_FAILED); 00109 } 00110 else if (ret & RET_FUNCTION_NOT_IMPLEMENTED) 00111 { 00112 std::cout << "AbstractColorCamera::TestCamera: Displaying camera information... NOT IMPLEMENTED" << std::endl; 00113 } 00114 else 00115 { 00116 std::cout << "AbstractColorCamera::TestCamera: Displaying camera information... OK." << std::endl; 00117 } 00118 std::cout << std::endl; 00119 00120 std::cout << "AbstractColorCamera::TestCamera: checking isInitialized()..." << std::endl; 00121 if (!isInitialized()) 00122 { 00123 std::cout << "AbstractColorCamera::TestCamera: checking isInitialized()... FAILED" << std::endl; 00124 return (RET_FAILED | RET_INIT_CHECK_FAILED); 00125 } 00126 std::cout << "AbstractColorCamera::TestCamera: checking isInitialized()... OK" << std::endl; 00127 std::cout << std::endl; 00128 00129 std::cout << "AbstractColorCamera::TestCamera: checking isOpen()..." << std::endl; 00130 if (!isOpen()) 00131 { 00132 std::cout << "AbstractColorCamera::TestCamera: checking isOpen()... FAILED" << std::endl; 00133 return (RET_FAILED | RET_OPEN_CHECK_FAILED); 00134 } 00135 std::cout << "AbstractColorCamera::TestCamera: checking isOpen()... OK" << std::endl; 00136 std::cout << std::endl; 00137 00138 std::cout << "AbstractColorCamera::TestCamera: checking Close()..." << std::endl; 00139 if (Close() & (RET_FAILED | RET_FUNCTION_NOT_IMPLEMENTED)) 00140 { 00141 std::cout << "AbstractColorCamera::TestCamera: checking Close()... FAILED" << std::endl; 00142 return (RET_FAILED | RET_CLOSE_CAMERA_FAILED); 00143 } 00144 std::cout << "AbstractColorCamera::TestCamera: checking Close()... OK" << std::endl; 00145 std::cout << std::endl; 00146 00147 std::cout << "AbstractColorCamera::TestCamera: checking isOpen()..." << std::endl; 00148 if (isOpen()) 00149 { 00150 std::cout << "AbstractColorCamera::TestCamera: checking isOpen()... FAILED" << std::endl; 00151 return (RET_FAILED | RET_OPEN_CHECK_FAILED); 00152 } 00153 std::cout << "AbstractColorCamera::TestCamera: checking isOpen()... OK" << std::endl; 00154 std::cout << std::endl; 00155 00156 std::cout << "AbstractColorCamera::TestCamera: checking Open()..." << std::endl; 00157 if (Open() & (RET_FAILED | RET_FUNCTION_NOT_IMPLEMENTED)) 00158 { 00159 std::cout << "AbstractColorCamera::TestCamera: checking Open()... FAILED" << std::endl; 00160 return (RET_FAILED | RET_OPEN_CAMERA_FAILED); 00161 } 00162 std::cout << "AbstractColorCamera::TestCamera: checking Open()... OK" << std::endl; 00163 std::cout << std::endl; 00164 00165 std::cout << "AbstractColorCamera::TestCamera: checking SaveParams()..." << std::endl; 00166 ret = SaveParameters("testSaveParams.xml"); 00167 if (ret & RET_FAILED) 00168 { 00169 std::cout << "AbstractColorCamera::TestCamera: checking SaveParams()... FAILED" << std::endl; 00170 return (RET_FAILED | RET_SAVE_PARAMS_FAILED); 00171 } 00172 else if (ret & RET_FUNCTION_NOT_IMPLEMENTED) 00173 { 00174 std::cout << "AbstractColorCamera::TestCamera: checking SaveParams()... NOT IMPLEMENTED" << std::endl; 00175 } 00176 else 00177 { 00178 std::cout << "AbstractColorCamera::TestCamera: checking SaveParams()... OK" << std::endl; 00179 } 00180 std::cout << std::endl; 00181 00182 std::cout << "AbstractColorCamera::TestCamera: checking SetPropertyDefaults()..." << std::endl; 00183 ret = SetPropertyDefaults(); 00184 if (ret & RET_FAILED) 00185 { 00186 std::cout << "AbstractColorCamera::TestCamera: checking SetPropertyDefaults()... FAILED" << std::endl; 00187 return (RET_FAILED | RET_SET_PROPERTY_DEFAULTS_FAILED); 00188 } 00189 else if (ret & RET_FUNCTION_NOT_IMPLEMENTED) 00190 { 00191 std::cout << "AbstractColorCamera::TestCamera: checking SetPropertyDefaults()... NOT IMPLEMENTED" << std::endl; 00192 } 00193 else 00194 { 00195 std::cout << "AbstractColorCamera::TestCamera: checking SetPropertyDefaults()... OK" << std::endl; 00196 } 00197 std::cout << std::endl; 00198 00199 return RET_OK; 00200 }