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 class SharedMemoryImageBuffer;
00034 class FvBaseThread;
00035 class FvAqtVisionThreads;
00036 namespace fawkes {
00037   class Logger;
00038   class Clock;
00039 #ifdef FVBASE_TIMETRACKER
00040   class TimeTracker;
00041 #endif
00042 }
00043
00044 class FvAcquisitionThread
00045 : public fawkes::Thread
00046 {
00047  public:
00048   /** Acquisition thread mode. */
00049   typedef enum {
00050     AqtCyclic,          /**< cyclic mode, use if there is at least one cyclic thread
00051                          * for this acquisition thread. */
00052     AqtContinuous       /**< continuous mode, use if there are only continuous threads
00053                          * for this acquisition thread. */
00054   } AqtMode;
00055
00056   FvAcquisitionThread(const char *id, Camera *camera,
00057                       fawkes::Logger *logger, fawkes::Clock *clock);
00058   virtual ~FvAcquisitionThread();
00059
00060   virtual void loop();
00061
00062   void set_aqtmode(AqtMode mode);
00063   AqtMode aqtmode();
00064   Camera *  camera_instance(colorspace_t cspace, bool deep_copy);
00065
00066   Camera *get_camera();
00067
00068   void set_vt_prepfin_hold(bool hold);
00069   void set_enabled(bool enabled);
00070
00071  public:
00072   /** Vision threads assigned to this acquisition thread. To be used only by the
00073    * base thread. */
00074   FvAqtVisionThreads       *vision_threads;
00075 
00076   /** Vision thread registered for raw camera access on this camera. */
00077   fawkes::Thread           *raw_subscriber_thread;
00078 
00079  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00080  protected: virtual void run() { Thread::run(); }
00081
00082  private:
00083   bool                      __enabled;
00084
00085   Camera                   *__camera;
00086   char                     *__image_id;
00087   fawkes::Logger           *__logger;
00088
00089   colorspace_t              __colorspace;
00090   unsigned int              __width;
00091   unsigned int              __height;
00092
00093   AqtMode                   __mode;
00094
00095   std::map<colorspace_t, SharedMemoryImageBuffer *> __shm;
00096   std::map<colorspace_t, SharedMemoryImageBuffer *>::iterator __shmit;
00097
00098 #ifdef FVBASE_TIMETRACKER
00099   fawkes::TimeTracker *__tt;
00100   unsigned int __loop_count;
00101   unsigned int __ttc_capture;
00102   unsigned int __ttc_lock;
00103   unsigned int __ttc_convert;
00104   unsigned int __ttc_unlock;
00105   unsigned int __ttc_dispose;
00106 #endif
00107 };
00108
00109
00110 #endif