CARMA C++
FrameGrabber.h
Go to the documentation of this file.
1 
11 #ifndef CARMA_ANTENNA_COMMON_FRAMEGRABBER_H
12 #define CARMA_ANTENNA_COMMON_FRAMEGRABBER_H
13 
14 #include "carma/antenna/common/Image.h"
15 #include "carma/util/PthreadMutex.h"
16 #include "carma/services/Table.h"
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 namespace carma {
23 namespace antenna {
24 namespace common {
25 
33  {
34  public:
35 
43  FrameGrabber( const std::string & fgdev,
44  int fginput,
45  bool emulate,
46  carma::services::Table* table=0);
47 
49 
53  ~FrameGrabber();
54 
59  void setPixelDepth( short depth );
60 
65  void setBrightness( short b );
66 
71  void setContrast( short c );
72 
76  typedef enum {
82 
88  void setResolution( ResolutionType resolution );
89 
90  ::std::pair<short, short> getResolution( ) const;
91 
92  static ::std::pair<short, short> getResolution(ResolutionType res);
93 
98  Image grabFrame( int numFrames = 1, std::vector<float>* data=0 );
99 
105  void setTestImage( const Image & image );
106 
107  void setDebug(carma::services::Table* table) {
108  table_ = table;
109  }
110 
111  public:
112 
113  carma::services::Table* table_;
114 
115  FrameGrabber( const FrameGrabber & ); // No copy
116  FrameGrabber & operator=( const FrameGrabber & ); // No assignment
117 
118  void initializeCaptureBuffer();
119  void createCaptureBuffer();
120  void unmapCaptureBuffer();
121 
122  class FrameGrabberPimpl; // Hide video interface
123  ::std::auto_ptr<FrameGrabberPimpl> pimpl_;
124 
125  ::std::pair<short, short> resolution_; // Current resolution
126  bool emulate_;
127 
128  //------------------------------------------------------------
129  // Capture buffer info
130  //------------------------------------------------------------
131 
132  void* imageBuffer_; // Where the image is held.
133 
134 #ifdef V4L2
135  std::vector<void*> captureBuffers_;
136 #endif
137 
138  unsigned bufLen_;
139  unsigned bufOffset_;
140 
141  carma::util::PthreadMutex mutex_; // Synchronize it all
142 
143  Image testImage_;
144 
145  }; // class FrameGrabber
146 
147 } // namespace common
148 } // namespace antenna
149 } // namespace carma
150 #endif // CARMA_FRAMEGRABBER_H
void setBrightness(short b)
Set brightness.
Encapsulate hardware access to framegrabber device.
Definition: FrameGrabber.h:32
void setTestImage(const Image &image)
Set test image when emulating.
void setPixelDepth(short depth)
Set pixel depth.
Common table functions.
void setContrast(short c)
Set contrast.
Simple ASCII Table format, fully memory based.
Definition: Table.h:126
FrameGrabber(const std::string &fgdev, int fginput, bool emulate, carma::services::Table *table=0)
Constructor.
void setResolution(ResolutionType resolution)
Set resolution.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41
ResolutionType
Supported resolution types.
Definition: FrameGrabber.h:76
Image grabFrame(int numFrames=1, std::vector< float > *data=0)
Grab a frame.
Number of supported resolutions.
Definition: FrameGrabber.h:80