runMACS
 All Data Structures Files Functions Variables Enumerations Enumerator Macros
ImageGrabber.cpp
Go to the documentation of this file.
1 #include <ImageGrabber.h>
2 
3 #ifdef HAVE_IMAQ
4 #include <ImaqGrabber.h>
5 #endif
6 #ifdef HAVE_DUMMY
7 #include <DummyGrabber.h>
8 #endif
9 #include <RemoteGrabber.h>
10 
11 #include <stringtricks.h>
12 
13 using namespace std;
14 
15 ImageGrabberException::ImageGrabberException(const std::string & _message) {
16  message = _message;
17 }
18 const char* ImageGrabberException::what() const throw() {
19  return message.c_str();
20 }
21 
23 
24 }
25 
27 
28 }
29 
30 ImageGrabber::ImageGrabber(const std::string & _deviceName,
31  const std::string & _deviceType,
32  const std::string & _deviceSource,
33  zmq::context_t & ctx,
34  const std::string & _brokerEndpoint) {
35  (void)_brokerEndpoint;
36 #ifdef HAVE_IMAQ
37  if(_deviceType.compare("imaq") == 0) {
38  impl = new _ImaqGrabberImpl(_deviceName, _deviceSource, ctx);
39  } else
40 #endif
41 #ifdef HAVE_DUMMY
42  if(_deviceType.compare("dummy") == 0) {
43  impl = new _DummyGrabberImpl(_deviceName, _deviceSource, ctx, _brokerEndpoint);
44  } else
45 #endif
46  if (_deviceType.compare("remote") == 0) {
47  impl = new _RemoteGrabberImpl(_deviceName, _deviceSource, ctx);
48  } else
49  {
50  throw ImageGrabberException(SSTR("unknown device type \"", _deviceType, "\"!"));
51  }
52 }
53 
55  delete impl;
56 }
57 
59  return impl->getWidth();
60 }
61 
63  return impl->getHeight();
64 }
65 
67  return impl->getBytesPerPixel();
68 }
69 
71  return impl->startServing();
72 }
73 
75  return impl->stopServing();
76 }
77 
78 void ImageGrabber::addEndpoint(const std::string & _endpoint) {
79  impl->addEndpoint(_endpoint);
80 }
81 
Base for all ImageGrabber related exceptions.
Definition: ImageGrabber.h:16
virtual ~_ImageGrabberImpl()=0
virtual const char * what() const
ImageGrabber(const std::string &_deviceName, const std::string &_deviceType, const std::string &_deviceSource, zmq::context_t &ctx, const std::string &_brokerEndpoint)
Setup a grabber.
STL namespace.
ImageGrabber implementation for IMAQ cameras.
Definition: ImaqGrabber.h:43
ImageGrabberException(const std::string &_message)
std::string SSTR(Args &&...components)
Creates a temporary string stream for string concatenation.
Definition: stringtricks.h:21
void startServing()
Start the server asynchronously.
int getBytesPerPixel()
void stopServing()
Stop the server.
void addEndpoint(const std::string &_endpoint)
Add a publisher endpoint.