60 isSubdeviceOwned =
false;
69 yCError(FRAMEGRABBER_NWS_YARP,
"Device is already opened");
75 if (config.
check(
"period",
"refresh period(in s) of the broadcasted values through yarp ports") && config.
find(
"period").
isFloat64()) {
78 yCInfo(FRAMEGRABBER_NWS_YARP)
79 <<
"Period parameter not found, using default of"
80 << DEFAULT_THREAD_PERIOD
83 PeriodicThread::setPeriod(period);
87 if (config.
check(
"capabilities",
"two capabilities supported, COLOR and RAW respectively for rgb and raw streaming")) {
90 }
else if (config.
find(
"capabilities").
asString() ==
"RAW") {
94 yCWarning(FRAMEGRABBER_NWS_YARP) <<
"'capabilities' parameter not found or misspelled, the option available are COLOR(default) and RAW, using default";
99 noDrop = config.
check(
"no_drop",
"if present, use strict policy for sending data");
103 std::string pImg_Name = config.
check(
"name",
yarp::os::Value(
"/grabber"),
"name of port to send data on").asString();
104 std::string rpcPort_Name = pImg_Name +
"/rpc";
106 if (!rpcPort.
open(rpcPort_Name)) {
107 yCError(FRAMEGRABBER_NWS_YARP) <<
"Unable to open rpc Port" << rpcPort_Name.c_str();
115 if (!pImg.
open(pImg_Name)) {
116 yCError(FRAMEGRABBER_NWS_YARP) <<
"Unable to open image streaming Port" << pImg_Name.c_str();
123 isSubdeviceOwned = config.
check(
"subdevice");
124 if (isSubdeviceOwned) {
134 p.setMonitor(config.getMonitor(),
"subdevice");
142 yCError(FRAMEGRABBER_NWS_YARP,
"Unable to open subdevice");
146 yCError(FRAMEGRABBER_NWS_YARP,
"Unable to attach subdevice");
150 yCInfo(FRAMEGRABBER_NWS_YARP) <<
"Running, waiting for attach...";
161 yCError(FRAMEGRABBER_NWS_YARP) <<
"Device " << poly <<
" to attach to is not valid ... cannot proceed";
165 poly->
view(iRgbVisualParams);
166 poly->
view(iFrameGrabberImage);
167 poly->
view(iFrameGrabberImageRaw);
168 poly->
view(iFrameGrabberControls);
169 poly->
view(iFrameGrabberControlsDC1394);
170 poly->
view(iPreciselyTimed);
174 if (iFrameGrabberImage ==
nullptr) {
175 yCError(FRAMEGRABBER_NWS_YARP) <<
"Capability \"COLOR\" required not supported";
180 if (iFrameGrabberImageRaw ==
nullptr) {
181 yCError(FRAMEGRABBER_NWS_YARP) <<
"Capability \"RAW\" required not supported";
187 if (iRgbVisualParams ==
nullptr) {
188 yCWarning(FRAMEGRABBER_NWS_YARP) <<
"Targets has not IVisualParamInterface, some features cannot be available";
192 if (iFrameGrabberImage !=
nullptr) {
193 if (!(frameGrabberImage_Responder.
configure(iFrameGrabberImage))) {
194 yCError(FRAMEGRABBER_NWS_YARP) <<
"Error configuring interfaces for parsers";
199 if (iFrameGrabberImageRaw !=
nullptr) {
200 if (!(frameGrabberImageRaw_Responder.
configure(iFrameGrabberImageRaw))) {
201 yCError(FRAMEGRABBER_NWS_YARP) <<
"Error configuring interfaces for parsers";
206 if (iRgbVisualParams !=
nullptr) {
207 if (!(rgbVisualParams_Responder.
configure(iRgbVisualParams))) {
208 yCError(FRAMEGRABBER_NWS_YARP) <<
"Error configuring interfaces for parsers";
212 if (iFrameGrabberControls !=
nullptr) {
213 if (!(frameGrabberControls_Responder.
configure(iFrameGrabberControls))) {
214 yCError(FRAMEGRABBER_NWS_YARP) <<
"Error configuring interfaces for parsers";
219 if (iFrameGrabberControlsDC1394 !=
nullptr) {
220 if (!(frameGrabberControlsDC1394_Responder.
configure(iFrameGrabberControlsDC1394))) {
221 yCError(FRAMEGRABBER_NWS_YARP) <<
"Error configuring interfaces for parsers";
226 return PeriodicThread::start();
236 iRgbVisualParams =
nullptr;
237 iFrameGrabberImage =
nullptr;
238 iFrameGrabberImageRaw =
nullptr;
239 iFrameGrabberControls =
nullptr;
240 iFrameGrabberControlsDC1394 =
nullptr;
241 iPreciselyTimed =
nullptr;
268 if (iFrameGrabberImage !=
nullptr) {
272 yCError(FRAMEGRABBER_NWS_YARP) <<
"Image not captured.. check hardware configuration";
277 if (iFrameGrabberImageRaw !=
nullptr) {
278 iFrameGrabberImageRaw->
getImage(*img_Raw);
279 flex_i.
swap(*img_Raw);
281 yCError(FRAMEGRABBER_NWS_YARP) <<
"Image not captured.. check hardware configuration";
285 if (iPreciselyTimed) {
302 return frameGrabberImage_Responder.
respond(command, reply);
304 return frameGrabberImageRaw_Responder.
respond(command, reply);
306 return frameGrabberControls_Responder.
respond(command, reply);
308 return rgbVisualParams_Responder.
respond(command, reply);
310 return frameGrabberControlsDC1394_Responder.
respond(command, reply);
312 yCError(FRAMEGRABBER_NWS_YARP) <<
"Command not recognized" << command.
toString();
constexpr yarp::conf::vocab32_t VOCAB_RGB_VISUAL_PARAMS
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_CONTROL_DC1394
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGERAW
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGE
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_CONTROL
constexpr double DEFAULT_THREAD_PERIOD
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.
void run() override
Loop function.
bool close() override
Close the DeviceDriver.
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply) override
Respond to a message.
~FrameGrabber_nws_yarp() override
bool view(T *&x)
Get an interface to the device driver.
virtual bool 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 close() override
Close the DeviceDriver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A simple collection of objects that can be described and transmitted in a portable way.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
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.
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 class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
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)
A single value (typically within a Bottle).
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual bool isFloat64() const
Checks if value is a 64-bit floating point number.
virtual std::string asString() const
Get string value.
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
bool configure(yarp::dev::IFrameGrabberControlsDC1394 *interface)
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
bool configure(yarp::dev::IFrameGrabberControls *interface)
bool configure(yarp::dev::IFrameGrabberOf< ImageType > *interface)
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
bool configure(yarp::dev::IRgbVisualParams *interface)
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
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.