Robot Devastation
YarpImageManager.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_YARP_IMAGE_MANAGER_HPP__
6 #define __RD_YARP_IMAGE_MANAGER_HPP__
7 
8 #include <string>
9 
10 #include <yarp/os/PortReaderBuffer.h>
11 #include <yarp/os/BufferedPort.h>
12 #include <yarp/os/Semaphore.h>
13 
14 #include "ImageManager.hpp"
15 
16 namespace rd{
17 
34  public yarp::os::TypedReaderCallback<Image>
35 {
36  public:
37  virtual bool start();
38  virtual bool stop();
39  virtual bool isStopped() const;
40  virtual bool setEnabled(bool enabled);
41  virtual bool configure(const std::string & parameter, const std::string & value);
42  virtual Image getImage() const;
43 
49  static bool RegisterManager();
50 
52  virtual ~YarpImageManager();
53 
55  static const std::string id;
56 
57  protected:
59  void onRead(Image& image);
60 
61  private:
69 
71  YarpImageManager & operator=(const YarpImageManager &);
72 
75 
77  mutable yarp::os::Semaphore semaphore;
78 
80  Image image;
81 
83  yarp::os::BufferedPort<Image> imagePort;
84 
86  std::string local_port_name;
87 
89  std::string remote_port_name;
90 
91  bool stopped;
92  bool enabled;
93 };
94 
95 
96 
97 }
98 
99 #endif //-- __RD_YARP_IMAGE_MANAGER_HPP__
rd::YarpImageManager::id
static const std::string id
String that identifies this manager.
Definition: YarpImageManager.hpp:55
rd::YarpImageManager::getImage
virtual Image getImage() const
Return the last received image.
Definition: YarpImageManager.cpp:118
rd::YarpImageManager::stop
virtual bool stop()
Stop capturing images.
Definition: YarpImageManager.cpp:79
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::YarpImageManager::semaphore
yarp::os::Semaphore semaphore
Semaphore to make the image manipulation thread-safe.
Definition: YarpImageManager.hpp:77
rd::YarpImageManager::start
virtual bool start()
Start to capture images.
Definition: YarpImageManager.cpp:18
rd::YarpImageManager::remote_port_name
std::string remote_port_name
Name of the camera (remote) yarp port.
Definition: YarpImageManager.hpp:89
rd::YarpImageManager::uniqueInstance
static YarpImageManager * uniqueInstance
Reference to this manager (unique instance)
Definition: YarpImageManager.hpp:74
rd::YarpImageManager::setEnabled
virtual bool setEnabled(bool enabled)
Enables/disables notifications to listeners.
Definition: YarpImageManager.cpp:96
rd::YarpImageManager::YarpImageManager
YarpImageManager()
Constructor.
Definition: YarpImageManager.cpp:162
rd::YarpImageManager::RegisterManager
static bool RegisterManager()
Register this manager in the ImageManager registry so that can be used.
Definition: YarpImageManager.cpp:127
rd::YarpImageManager::~YarpImageManager
virtual ~YarpImageManager()
Destructor. Used to reset the local static reference after destroying this manager.
Definition: YarpImageManager.cpp:137
rd::YarpImageManager::isStopped
virtual bool isStopped() const
True if the manager is not active.
Definition: YarpImageManager.cpp:91
rd::YarpImageManager::image
Image image
Last image received.
Definition: YarpImageManager.hpp:80
rd::YarpImageManager
Image input manager based in YARP.
Definition: YarpImageManager.hpp:33
rd::YarpImageManager::onRead
void onRead(Image &image)
Yarp event for incoming messages.
Definition: YarpImageManager.cpp:142
rd::YarpImageManager::configure
virtual bool configure(const std::string &parameter, const std::string &value)
Configures a parameter with a value.
Definition: YarpImageManager.cpp:102
rd::YarpImageManager::local_port_name
std::string local_port_name
Name of the local yarp port.
Definition: YarpImageManager.hpp:86
rd::YarpImageManager::imagePort
yarp::os::BufferedPort< Image > imagePort
Yarp port to communicate with the remote camera.
Definition: YarpImageManager.hpp:83
rd::ImageManager
Generic image input manager.
Definition: ImageManager.hpp:39