runMACS
 All Data Structures Files Functions Variables Enumerations Enumerator Macros
ImaqGrabber.h
Go to the documentation of this file.
1 #ifndef IMAQ_GRABBER_H
2 #define IMAQ_GRABBER_H
3 
4 #include <interfaces/IImageStreamExtractor.h>
5 #include <ImageGrabber.h>
6 
7 #include <zmq.hpp>
8 
9 /* c++03 std lib */
10 #include <exception>
11 #include <string>
12 #include <vector>
13 #include <list>
14 
15 /* c++11 std lib additions */
16 #include <thread>
17 #include <mutex>
18 #include <atomic>
19 #include <condition_variable>
20 
21 /* 3rdparty libraries */
22 #define NI_STDCALL __stdcall
23 #include <niimaq.h>
24 
29 class ImaqException: public std::exception {
30 public:
31  ImaqException(const std::string & _message);
32  ~ImaqException() throw();
33  virtual const char* what() const throw();
34 private:
35  std::string message;
36 };
37 
44  friend ImageGrabber;
45 private:
51  _ImaqGrabberImpl(const std::string & _deviceName, const std::string & _deviceSource, zmq::context_t & _ctx);
53 
59  int getInteger(uInt32 attr);
64  int getWidth();
69  int getHeight();
74  int getBytesPerPixel();
77  void startServing();
80  void stopServing();
81  void acquisition();
82  void acquireBuffer(int bufferId);
83  void releaseBuffer(int bufferId);
92  void addEndpoint(const std::string & _endpoint);
93 
94  std::string deviceName;
95  std::string deviceSource;
96  INTERFACE_ID ifid;
97  SESSION_ID sid;
98  bool interfaceOpen;
99  bool sessionOpen;
100  int totalLostFrames = 0;
101  std::thread acquisitionThread;
102  volatile bool enableAcquisition = false;
103  std::vector<std::atomic<int>*> bufferUsers;
104  std::atomic<int> openBuffers;
105  std::atomic<int> totalBufferUsers;
106  std::condition_variable bufferFreeNotifier;
107 
108  zmq::context_t & ctx;
109  std::list<std::string> endpoints;
110 };
111 
112 #endif /* IMAQ_GRABBER_H */
Base for all Imaq related exceptions.
Definition: ImaqGrabber.h:29
ImageGrabber implementation for IMAQ cameras.
Definition: ImaqGrabber.h:43
ImaqException(const std::string &_message)
Definition: ImaqGrabber.cpp:23
Public interface to an ImageGrabber grabber.
Definition: ImageGrabber.h:45
virtual const char * what() const
Definition: ImaqGrabber.cpp:26