00001 /* --------------------------------------------------------------------------- 00002 Phission : 00003 Realtime Vision Processing System 00004 00005 Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu) 00006 University of Massachusetts at Lowell, 00007 Laboratory for Artificial Intelligence and Robotics 00008 00009 This file is part of Phission. 00010 00011 Phission is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU Lesser General Public License as published by 00013 the Free Software Foundation; either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 Phission is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public License 00022 along with Phission; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 ---------------------------------------------------------------------------*/ 00026 #ifndef _PHPIPELINE_H 00027 #define _PHPIPELINE_H 00028 00029 #include <phStandard.h> 00030 #include <phLiveObject.h> 00031 #include <phImage.h> 00032 #include <phFilter.h> 00033 #include <phThread.h> 00034 #include <phObjectList.h> 00035 #include <phSemaphore.h> 00036 #include <phTimeInterval.h> 00037 00043 /* These are used in 'runFilters' to decide which input should be used. 00044 * the pipeline thread by default will use m_liveSourceInput if defined, 00045 * otherwise it'll listen to the internal m_inputImage. 00046 * 'runFilters' isn't the thread however, so one can decide which input 00047 * to use. */ 00048 #define phPipeline_Input 0 00049 #define phPipeline_LiveSource 1 00050 #define phPipeline_Decide -1 00051 /* end \addtogroup PhissionSystem */ 00053 00054 /* ------------------------------------------------------------------------ */ 00073 PHAPI(class) phPipeline : public phThread 00074 { 00075 private: 00076 phImage m_inputImage; 00077 phImage m_outputImage; 00078 00079 /* live source stuff; If there is no live source image, the processing 00080 * thread listens to the input image */ 00081 phLiveObject *m_liveSource; 00082 phSemaphore m_liveSourceSignal; 00083 00084 phImage m_workspaceImage; 00085 phImage m_originalImage; 00086 00087 uint32_t m_filterCount; 00088 phFilter **m_filterArray; 00089 00090 phObjectList m_filters; 00091 phSemaphore m_generateSignal; 00092 00093 int generateFilterArray(); 00094 int checkSignals(); 00095 00096 /* Unprotected class, needs a mutex and functional access only */ 00097 /* The average running time isn't protected from overflow, 00098 * have to use resetAverage to prevent overflowing, although, 00099 * chances are low that overflow will happen */ 00100 phMutex m_timeLock; 00101 phTimeStamp m_runtime; 00102 phTimeStamp m_averageRuntime; 00103 double m_total_nsec; 00104 uintmax_t m_averageSamples; 00105 int m_do_timing; 00106 int m_timingEnabled; 00107 phSemaphore m_timingEnabledSignal; 00108 int applyRuntime(phTimeStamp &runtime); 00109 00110 00111 protected: 00112 virtual int wakeup(); 00113 virtual int run(); 00114 00115 public: 00116 phPipeline(); 00117 ~phPipeline(); 00118 00119 /*-----------------------------------------------------------------------*/ 00120 /* Image methods */ 00121 /*-----------------------------------------------------------------------*/ 00122 /* pointer to device's public image */ 00123 int setInputImage ( phImage &newImage ); 00124 int copyOutputImage ( phImage ©to ); 00125 00126 const phImage &getInputImage (); 00127 const phImage &getOutputImage (); 00128 00129 /*-----------------------------------------------------------------------*/ 00130 /* Pipeline phFilter methods */ 00131 /*-----------------------------------------------------------------------*/ 00136 int add ( phFilter *filter ); 00140 int remove ( phFilter *filter ); 00144 int empty ( ); 00149 int query ( phFilter *filter ); 00150 00151 /*-----------------------------------------------------------------------*/ 00152 /* Timing Features */ 00153 /*-----------------------------------------------------------------------*/ 00159 int enableTiming (); 00160 int disableTiming (); 00161 int isTimingEnabled (); 00165 phTimeStamp runtime (); 00170 phTimeStamp averageRuntime (); 00175 uintmax_t averageSamples (); 00181 int resetAverage (); 00182 00183 /*-----------------------------------------------------------------------*/ 00184 /* Pipeline processing/activity features */ 00185 /*-----------------------------------------------------------------------*/ 00196 int runFilters( int32_t use_input_image = phPipeline_Decide ); 00197 int print(); 00198 00199 int isPipelineActive(); 00200 int startPipeline (); 00201 int stopPipeline (); 00202 00203 /*-----------------------------------------------------------------------*/ 00204 /* Pipeline live source features */ 00205 /*-----------------------------------------------------------------------*/ 00206 phLiveObject *getLiveSourceOutput (); 00207 int setLiveSourceInput ( phLiveObject *img ); 00208 00209 phLiveObject *getOutput(); 00210 int setInput ( phLiveObject *img ); 00211 }; 00212 00213 #endif /* _PHPIPELINE_H */
Copyright (C) 2002 - 2007 |
Philip D.S. Thoren ( pthoren@users.sourceforge.net ) University Of Massachusetts at Lowell Robotics Lab |