Robot Devastation
YarpLocalImageManager.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_LOCAL_IMAGE_MANAGER_HPP__
6 #define __RD_YARP_LOCAL_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 #include <yarp/dev/PolyDriver.h>
14 
15 #include "ImageManager.hpp"
16 
17 namespace rd{
18 
35  public yarp::os::TypedReaderCallback<Image>
36 {
37  public:
38  virtual bool start();
39  virtual bool stop();
40  virtual bool isStopped() const;
41  virtual bool setEnabled(bool enabled);
42  virtual bool configure(const std::string & parameter, const std::string & value);
43  virtual Image getImage() const;
44 
50  static bool RegisterManager();
51 
53  virtual ~YarpLocalImageManager();
54 
56  static const std::string id;
57 
58  protected:
60  void onRead(Image& image);
61 
62  private:
70 
72  YarpLocalImageManager & operator=(const YarpLocalImageManager &);
73 
76 
78  mutable yarp::os::Semaphore semaphore;
79 
81  Image image;
82 
84  yarp::os::BufferedPort<Image> imagePort;
85 
87  std::string local_port_name;
88 
90  std::string remote_port_name;
91 
92  bool stopped;
93  bool enabled;
94 
95  yarp::dev::PolyDriver cameraDevice;
96 
98  int camera_id;
99 };
100 
101 
102 
103 }
104 
105 #endif //-- __RD_YARP_LOCAL_IMAGE_MANAGER_HPP__
rd::YarpLocalImageManager::configure
virtual bool configure(const std::string &parameter, const std::string &value)
Configures a parameter with a value.
Definition: YarpLocalImageManager.cpp:83
rd::YarpLocalImageManager::YarpLocalImageManager
YarpLocalImageManager()
Constructor.
Definition: YarpLocalImageManager.cpp:148
rd::YarpLocalImageManager::uniqueInstance
static YarpLocalImageManager * uniqueInstance
Reference to this manager (unique instance)
Definition: YarpLocalImageManager.hpp:75
rd::YarpLocalImageManager::semaphore
yarp::os::Semaphore semaphore
Semaphore to make the image manipulation thread-safe.
Definition: YarpLocalImageManager.hpp:78
rd::YarpLocalImageManager::remote_port_name
std::string remote_port_name
Name of the camera (remote) yarp port.
Definition: YarpLocalImageManager.hpp:90
rd::YarpLocalImageManager::~YarpLocalImageManager
virtual ~YarpLocalImageManager()
Destructor. Used to reset the local static reference after destroying this manager.
Definition: YarpLocalImageManager.cpp:124
rd::YarpLocalImageManager::stop
virtual bool stop()
Stop capturing images.
Definition: YarpLocalImageManager.cpp:58
rd::YarpLocalImageManager::id
static const std::string id
String that identifies this manager.
Definition: YarpLocalImageManager.hpp:56
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::YarpLocalImageManager::start
virtual bool start()
Start to capture images.
Definition: YarpLocalImageManager.cpp:20
rd::YarpLocalImageManager
Image input manager based in YARP.
Definition: YarpLocalImageManager.hpp:34
rd::YarpLocalImageManager::getImage
virtual Image getImage() const
Return the last received image.
Definition: YarpLocalImageManager.cpp:105
rd::YarpLocalImageManager::camera_id
int camera_id
Used to select when several cameras are attached.
Definition: YarpLocalImageManager.hpp:98
rd::YarpLocalImageManager::imagePort
yarp::os::BufferedPort< Image > imagePort
Yarp port to communicate with the remote camera.
Definition: YarpLocalImageManager.hpp:84
rd::YarpLocalImageManager::setEnabled
virtual bool setEnabled(bool enabled)
Enables/disables notifications to listeners.
Definition: YarpLocalImageManager.cpp:77
rd::YarpLocalImageManager::local_port_name
std::string local_port_name
Name of the local yarp port.
Definition: YarpLocalImageManager.hpp:87
rd::YarpLocalImageManager::isStopped
virtual bool isStopped() const
True if the manager is not active.
Definition: YarpLocalImageManager.cpp:72
rd::YarpLocalImageManager::RegisterManager
static bool RegisterManager()
Register this manager in the ImageManager registry so that can be used.
Definition: YarpLocalImageManager.cpp:114
rd::YarpLocalImageManager::onRead
void onRead(Image &image)
Yarp event for incoming messages.
Definition: YarpLocalImageManager.cpp:129
rd::YarpLocalImageManager::image
Image image
Last image received.
Definition: YarpLocalImageManager.hpp:81
rd::ImageManager
Generic image input manager.
Definition: ImageManager.hpp:39