62 else {
yCError(FRAMEGRABBER_NWS_YARP) <<
"'capabilities' parameter unsupported value";
return false;}
65 std::string pImg_Name =
m_name;
66 std::string rpcPort_Name = pImg_Name +
"/rpc";
68 if (!rpcPort.
open(rpcPort_Name)) {
69 yCError(FRAMEGRABBER_NWS_YARP) <<
"Unable to open rpc Port" << rpcPort_Name.c_str();
77 if (!pImg.
open(pImg_Name)) {
78 yCError(FRAMEGRABBER_NWS_YARP) <<
"Unable to open image streaming Port" << pImg_Name.c_str();
83 yCInfo(FRAMEGRABBER_NWS_YARP) <<
"Running, waiting for attach...";
90 std::lock_guard lock (m_mutex);
94 yCError(FRAMEGRABBER_NWS_YARP) <<
"Device " << poly <<
" to attach to is not valid ... cannot proceed";
99 poly->
view(m_iRgbVisualParams);
100 poly->
view(m_iFrameGrabberControls);
101 poly->
view(m_iFrameGrabberControlsDC1394);
102 poly->
view(m_iFrameGrabberImage);
103 poly->
view(m_iFrameGrabberImageRaw);
104 poly->
view(m_iPreciselyTimed);
108 if (m_iFrameGrabberImage ==
nullptr) {
109 yCError(FRAMEGRABBER_NWS_YARP) <<
"Capability \"COLOR\" required not supported";
114 if (m_iFrameGrabberImageRaw ==
nullptr) {
115 yCError(FRAMEGRABBER_NWS_YARP) <<
"Capability \"RAW\" required not supported";
121 if (m_iRgbVisualParams ==
nullptr) {
122 yCWarning(FRAMEGRABBER_NWS_YARP) <<
"Targets has not IVisualParamInterface, some features cannot be available";
125 m_RPC_FrameGrabber = std::make_unique<FrameGrabberMsgsImpl>(m_iRgbVisualParams, m_iFrameGrabberControls, m_iFrameGrabberControlsDC1394, m_iFrameGrabberImage, m_iFrameGrabberImageRaw);
127 return PeriodicThread::start();
133 std::lock_guard lock (m_mutex);
139 m_iFrameGrabberImage =
nullptr;
140 m_iFrameGrabberImageRaw =
nullptr;
141 m_iPreciselyTimed =
nullptr;
142 m_iRgbVisualParams =
nullptr;
143 m_iFrameGrabberControls =
nullptr;
144 m_iFrameGrabberControlsDC1394 =
nullptr;
151 if (m_cap == COLOR) {
172 if (m_iFrameGrabberImage !=
nullptr) {
173 if (m_iFrameGrabberImage->
getImage(*img))
176 {
yCError(FRAMEGRABBER_NWS_YARP) <<
"Image not captured (getImage failed). Check hardware configuration.";}
178 yCError(FRAMEGRABBER_NWS_YARP) <<
"Image not captured (invalid interface). Check hw/sw configuration.";
184 if (m_iFrameGrabberImageRaw !=
nullptr) {
185 if (m_iFrameGrabberImageRaw->
getImage(*img_Raw))
186 {flex_i.
swap(*img_Raw);}
188 {
yCError(FRAMEGRABBER_NWS_YARP) <<
"Image not captured (getImage failed). Check hardware configuration.";}
190 yCError(FRAMEGRABBER_NWS_YARP) <<
"Image not captured (invalid interface). Check hw/sw configuration.";
194 if (m_iPreciselyTimed)
208 if (!connection.
isValid()) {
return false;}
209 if (!m_RPC_FrameGrabber) {
return false;}
211 std::lock_guard<std::mutex> lock(m_mutex);
213 if (m_RPC_FrameGrabber->read(connection))
218 yCError(FRAMEGRABBER_NWS_YARP) <<
"read() Command failed";
static constexpr double DEFAULT_THREAD_PERIOD
std::string m_capabilities
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
bool threadInit() override
Initialization method.
virtual bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
void run() override
Loop function.
bool close() override
Close the DeviceDriver.
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
~FrameGrabber_nws_yarp() override
bool view(T *&x)
Get an interface to the device driver.
virtual yarp::dev::ReturnValue getImage(ImageType &image)=0
Get an image from the frame grabber.
virtual yarp::os::Stamp getLastInputStamp()=0
Return the time stamp relative to the last acquisition.
A container for a device driver.
bool isValid() const
Check if device is valid.
void promiseType(const Type &typ) override
Commit the port to a particular type of data.
void close() override
Stop port activity.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
void setReader(PortReader &reader) override
Set an external reader for port data.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
int getOutputCount() override
Determine how many output connections this port has.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
An interface for reading from a network connection.
virtual bool isValid() const =0
bool isRunning() const
Returns true when the thread is started, false otherwise.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A base class for nested structures that can be searched.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
static Type byName(const char *name)
Image class with user control of representation details.
bool swap(Image &alt)
swap operator.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
double now()
Return the current time in seconds, relative to an arbitrary starting point.