Fawkes API Fawkes Development Version

acquisition_thread.h

00001 
00002 /***************************************************************************
00003  *  acquisition_thread.h - FireVision Acquisition Thread
00004  *
00005  *  Created: Wed Jun 06 19:01:10 2007
00006  *  Copyright  2006-2009  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __FIREVISION_APPS_BASE_ACQUISITION_THREAD_H_
00024 #define __FIREVISION_APPS_BASE_ACQUISITION_THREAD_H_
00025 
00026 #include <core/threading/thread.h>
00027 
00028 #include <cams/shmem.h>
00029 #include <fvutils/color/colorspaces.h>
00030 
00031 #include <map>
00032 
00033 namespace fawkes {
00034   class Logger;
00035   class Clock;
00036 #ifdef FVBASE_TIMETRACKER
00037   class TimeTracker;
00038 #endif
00039 }
00040 namespace firevision {
00041   class SharedMemoryImageBuffer;
00042 }
00043 class FvBaseThread;
00044 class FvAqtVisionThreads;
00045 
00046 class FvAcquisitionThread : public fawkes::Thread
00047 {
00048  public:
00049   /** Acquisition thread mode. */
00050   typedef enum {
00051     AqtCyclic,          /**< cyclic mode, use if there is at least one cyclic thread
00052                          * for this acquisition thread. */
00053     AqtContinuous       /**< continuous mode, use if there are only continuous threads
00054                          * for this acquisition thread. */
00055   } AqtMode;
00056 
00057   FvAcquisitionThread(const char *id, firevision::Camera *camera,
00058                       fawkes::Logger *logger, fawkes::Clock *clock);
00059   virtual ~FvAcquisitionThread();
00060 
00061   virtual void loop();
00062 
00063   void set_aqtmode(AqtMode mode);
00064   AqtMode aqtmode();
00065   firevision::Camera *  camera_instance(firevision::colorspace_t cspace, bool deep_copy);
00066 
00067   firevision::Camera *get_camera();
00068 
00069   void set_vt_prepfin_hold(bool hold);
00070   void set_enabled(bool enabled);
00071 
00072  public:
00073   /** Vision threads assigned to this acquisition thread. To be used only by the
00074    * base thread. */
00075   FvAqtVisionThreads       *vision_threads;
00076 
00077   /** Vision thread registered for raw camera access on this camera. */
00078   fawkes::Thread           *raw_subscriber_thread;
00079 
00080  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00081  protected: virtual void run() { Thread::run(); }
00082 
00083  private:
00084   bool                      __enabled;
00085 
00086   firevision::Camera       *__camera;
00087   char                     *__image_id;
00088   fawkes::Logger           *__logger;
00089 
00090   firevision::colorspace_t  __colorspace;
00091   unsigned int              __width;
00092   unsigned int              __height;
00093 
00094   AqtMode                   __mode;
00095 
00096   std::map<firevision::colorspace_t, firevision::SharedMemoryImageBuffer *> __shm;
00097   std::map<firevision::colorspace_t, firevision::SharedMemoryImageBuffer *>::iterator __shmit;
00098 
00099 #ifdef FVBASE_TIMETRACKER
00100   fawkes::TimeTracker *__tt;
00101   unsigned int __loop_count;
00102   unsigned int __ttc_capture;
00103   unsigned int __ttc_lock;
00104   unsigned int __ttc_convert;
00105   unsigned int __ttc_unlock;
00106   unsigned int __ttc_dispose;
00107 #endif
00108 };
00109 
00110 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends