Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
acquisition_thread.h
1 
2 /***************************************************************************
3  * acquisition_thread.h - FireVision Acquisition Thread
4  *
5  * Created: Wed Jun 06 19:01:10 2007
6  * Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __FIREVISION_APPS_BASE_ACQUISITION_THREAD_H_
24 #define __FIREVISION_APPS_BASE_ACQUISITION_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 
28 #include <fvcams/shmem.h>
29 #include <fvutils/color/colorspaces.h>
30 
31 #include <map>
32 
33 namespace fawkes {
34  class Logger;
35  class Clock;
36 #ifdef FVBASE_TIMETRACKER
37  class TimeTracker;
38 #endif
39 }
40 namespace firevision {
41  class SharedMemoryImageBuffer;
42 }
43 class FvBaseThread;
44 class FvAqtVisionThreads;
45 
47 {
48  public:
49  /** Acquisition thread mode. */
50  typedef enum {
51  AqtCyclic, /**< cyclic mode, use if there is at least one cyclic thread
52  * for this acquisition thread. */
53  AqtContinuous /**< continuous mode, use if there are only continuous threads
54  * for this acquisition thread. */
55  } AqtMode;
56 
57  FvAcquisitionThread(const char *id, firevision::Camera *camera,
58  fawkes::Logger *logger, fawkes::Clock *clock);
59  virtual ~FvAcquisitionThread();
60 
61  virtual void loop();
62 
63  void set_aqtmode(AqtMode mode);
64  AqtMode aqtmode();
65  firevision::Camera * camera_instance(firevision::colorspace_t cspace, bool deep_copy);
66 
68 
69  void set_vt_prepfin_hold(bool hold);
70  void set_enabled(bool enabled);
71 
72  public:
73  /** Vision threads assigned to this acquisition thread. To be used only by the
74  * base thread. */
76 
77  /** Vision thread registered for raw camera access on this camera. */
79 
80  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
81  protected: virtual void run() { Thread::run(); }
82 
83  private:
84  bool __enabled;
85 
86  firevision::Camera *__camera;
87  char *__image_id;
88  fawkes::Logger *__logger;
89 
90  firevision::colorspace_t __colorspace;
91  unsigned int __width;
92  unsigned int __height;
93 
94  AqtMode __mode;
95 
96  std::map<firevision::colorspace_t, firevision::SharedMemoryImageBuffer *> __shm;
97  std::map<firevision::colorspace_t, firevision::SharedMemoryImageBuffer *>::iterator __shmit;
98 
99 #ifdef FVBASE_TIMETRACKER
100  fawkes::TimeTracker *__tt;
101  unsigned int __loop_count;
102  unsigned int __ttc_capture;
103  unsigned int __ttc_lock;
104  unsigned int __ttc_convert;
105  unsigned int __ttc_unlock;
106  unsigned int __ttc_dispose;
107 #endif
108 };
109 
110 #endif
void set_aqtmode(AqtMode mode)
Set acquisition thread mode.
AqtMode
Acquisition thread mode.
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:35
fawkes::Thread * raw_subscriber_thread
Vision thread registered for raw camera access on this camera.
This is supposed to be the central clock in Fawkes.
Definition: clock.h:34
FvAqtVisionThreads * vision_threads
Vision threads assigned to this acquisition thread.
virtual void run()
Stub to see name in backtrace for easier debugging.
Aquisition-dependant threads.
Thread class encapsulation of pthreads.
Definition: thread.h:42
FireVision base application acquisition thread.
virtual ~FvAcquisitionThread()
Destructor.
FireVision base thread.
Definition: base_thread.h:46
Time tracking utility.
Definition: tracker.h:38
firevision::Camera * get_camera()
Get the Camera of this acquisition thread.
void set_vt_prepfin_hold(bool hold)
Set prepfin hold status for vision threads.
firevision::Camera * camera_instance(firevision::colorspace_t cspace, bool deep_copy)
Get a camera instance.
virtual void loop()
Code to execute in the thread.
cyclic mode, use if there is at least one cyclic thread for this acquisition thread.
void set_enabled(bool enabled)
Enable or disable image retrieval.
FvAcquisitionThread(const char *id, firevision::Camera *camera, fawkes::Logger *logger, fawkes::Clock *clock)
Constructor.
continuous mode, use if there are only continuous threads for this acquisition thread.
AqtMode aqtmode()
Get acquisition thread mode.
Interface for logging.
Definition: logger.h:34