24template <
typename ImageType>
27 m_thriftClient = thriftClient;
30template <
typename ImageType>
33 std::lock_guard<std::mutex> lock(m_mutex);
35 if (!m_streamReceiver)
37 if (!m_thriftClient) {
41 auto ret = m_thriftClient->getHeightRPC();
49 return m_streamReceiver->lastHeight();
53template <
typename ImageType>
56 std::lock_guard<std::mutex> lock(m_mutex);
58 if (!m_streamReceiver)
65 auto ret = m_thriftClient->getWidthRPC();
74 return m_streamReceiver->lastWidth();
78template <
typename ImageType>
81 std::lock_guard<std::mutex> lock(m_mutex);
83 if (!m_streamReceiver)
87 return ReturnValue::return_code::return_value_error_generic;
89 auto ret = m_thriftClient->getImageRPC();
97 bool b= m_streamReceiver->lastImage(
image);
99 return ReturnValue::return_code::return_value_error_not_ready;
104template <
typename ImageType>
106 std::vector<yarp::dev::vertex_t> vertices,
109 std::lock_guard<std::mutex> lock(m_mutex);
111 if(!m_streamReceiver)
113 if (!m_thriftClient) {
114 return ReturnValue::return_code::return_value_error_generic;
116 std::vector<yarp::dev::vertex_t> vv;
117 vv.resize(vertices.size());
118 for (
size_t i = 0; i < vertices.size(); i++)
122 auto ret = m_thriftClient->getImageCropRPC(cropType, vv);
130 if (vertices.size() != 2) {
131 yCError(FRAMEGRABBER_NWC_YARP,
"GetImageCrop failed: RECT mode requires 2 vertices");
132 return ReturnValue::return_code::return_value_error_method_failed;
135 bool b = m_streamReceiver->lastImage(full);
138 yCError(FRAMEGRABBER_NWC_YARP,
"GetImageCrop failed: No image received");
139 return ReturnValue::return_code::return_value_error_not_ready;
142 std::pair<unsigned int, unsigned int> v0;
143 v0.first = vertices[0].x;
144 v0.second = vertices[0].y;
145 std::pair<unsigned int, unsigned int> v1;
146 v1.first = vertices[1].x;
147 v1.second = vertices[1].y;
149 yCError(FRAMEGRABBER_NWC_YARP,
"GetImageCrop failed: utils::cropRect error: (%d, %d) (%d, %d)",
154 return ReturnValue::return_code::return_value_error_method_failed;
158 yCError(FRAMEGRABBER_NWC_YARP,
"List type not yet implemented");
159 return ReturnValue::return_code::return_value_error_not_implemented_by_device;
166template <
typename ImageType>
169 std::lock_guard<std::mutex> lock(m_mutex);
170 m_streamReceiver = streamReceiver;
198 std::string rpc_local =
m_local +
"/rpc_client";
199 std::string rpc_remote =
m_remote +
"/rpc";
200 if (!m_rpcPort.
open(rpc_local)) {
201 yCError(FRAMEGRABBER_NWC_YARP) <<
"Failed to open " << rpc_local <<
"port.";
205 yCInfo(FRAMEGRABBER_NWC_YARP) <<
"Connecting" << m_rpcPort.
getName() <<
"to" << rpc_remote;
207 yCError(FRAMEGRABBER_NWC_YARP) <<
"Failed to connect" << m_rpcPort.
getName() <<
"to" << rpc_remote;
211 yCInfo(FRAMEGRABBER_NWC_YARP) <<
"No remote specified. Waiting for connection";
217 yCError(FRAMEGRABBER_NWC_YARP,
"Error! Cannot attach the port as a client");
235 m_streamReceiver.
close();
252 std::lock_guard <std::mutex> lg(m_mutex);
259 std::lock_guard <std::mutex> lg(m_mutex);
266 std::lock_guard <std::mutex> lg(m_mutex);
274 std::lock_guard <std::mutex> lg(m_mutex);
283 std::lock_guard <std::mutex> lg(m_mutex);
290 std::lock_guard <std::mutex> lg(m_mutex);
294 verticalFov = r.verticalFOV;
300 std::lock_guard <std::mutex> lg(m_mutex);
301 auto r = m_frameGrabber_RPC.
setRgbFOVRPC(horizontalFov, verticalFov);
307 std::lock_guard <std::mutex> lg(m_mutex);
309 intrinsic = r.params;
315 std::lock_guard <std::mutex> lg(m_mutex);
323 std::lock_guard <std::mutex> lg(m_mutex);
333 std::lock_guard<std::mutex> lg(m_mutex);
342 std::lock_guard<std::mutex> lg(m_mutex);
350 std::lock_guard<std::mutex> lg(m_mutex);
357 std::lock_guard<std::mutex> lg(m_mutex);
365 std::lock_guard<std::mutex> lg(m_mutex);
372 std::lock_guard<std::mutex> lg(m_mutex);
381 std::lock_guard<std::mutex> lg(m_mutex);
389 std::lock_guard<std::mutex> lg(m_mutex);
396 std::lock_guard<std::mutex> lg(m_mutex);
404 std::lock_guard<std::mutex> lg(m_mutex);
412 std::lock_guard<std::mutex> lg(m_mutex);
420 std::lock_guard<std::mutex> lg(m_mutex);
428 std::lock_guard<std::mutex> lg(m_mutex);
435 std::lock_guard<std::mutex> lg(m_mutex);
443 std::lock_guard<std::mutex> lg(m_mutex);
453 std::lock_guard<std::mutex> lg(m_mutex);
461 std::lock_guard<std::mutex> lg(m_mutex);
469 std::lock_guard<std::mutex> lg(m_mutex);
476 std::lock_guard<std::mutex> lg(m_mutex);
484 std::lock_guard<std::mutex> lg(m_mutex);
492 std::lock_guard<std::mutex> lg(m_mutex);
499 std::lock_guard<std::mutex> lg(m_mutex);
507 std::lock_guard<std::mutex> lg(m_mutex);
514 std::lock_guard<std::mutex> lg(m_mutex);
522 std::lock_guard<std::mutex> lg(m_mutex);
530 std::lock_guard<std::mutex> lg(m_mutex);
539 unsigned int& xoffstep,
540 unsigned int& yoffstep)
542 std::lock_guard<std::mutex> lg(m_mutex);
548 xoffstep = r.xoffstep;
549 yoffstep = r.yoffstep;
555 std::lock_guard<std::mutex> lg(m_mutex);
566 std::lock_guard<std::mutex> lg(m_mutex);
573 std::lock_guard<std::mutex> lg(m_mutex);
580 std::lock_guard<std::mutex> lg(m_mutex);
588 std::lock_guard<std::mutex> lg(m_mutex);
595 std::lock_guard<std::mutex> lg(m_mutex);
603 std::lock_guard<std::mutex> lg(m_mutex);
610 std::lock_guard<std::mutex> lg(m_mutex);
617 std::lock_guard<std::mutex> lg(m_mutex);
624 std::lock_guard<std::mutex> lg(m_mutex);
631 std::lock_guard<std::mutex> lg(m_mutex);
638 std::lock_guard<std::mutex> lg(m_mutex);
646 std::lock_guard<std::mutex> lg(m_mutex);
virtual IFrameGrabberControlMsgs_return_getActive getActiveRPC(const std::int32_t feature)
virtual yarp::dev::ReturnValue setColorCodingDC1394RPC(const std::int32_t coding)
virtual yarp::dev::ReturnValue setRgbFOVRPC(const double horizontalFov, const double verticalFov)
virtual yarp::dev::ReturnValue setFeature2RPC(const std::int32_t feature, const double value1, const double value2)
virtual yarp::dev::ReturnValue setOnePushRPC(const std::int32_t feature)
virtual yarp::dev::ReturnValue setFormat7WindowDC1394RPC(const std::int32_t xdim, const std::int32_t ydim, const std::int32_t x0, const std::int32_t y0)
virtual yarp::dev::ReturnValue setVideoModeDC1394RPC(const std::int32_t videomode)
virtual yarp::dev::ReturnValue setBytesPerPacketDC1394RPC(const std::int32_t bpp)
virtual IFrameGrabberControlDC1394Msgs_return_getFormat7MaxWindowDC1394 getFormat7MaxWindowDC1394RPC()
virtual IRGBVisualParamsMsgs_return_getRgbHeight getRgbHeightRPC()
virtual bool checkProtocolVersion()
virtual IFrameGrabberControlDC1394Msgs_return_getOperationModeDC1394 getOperationModeDC1394RPC()
virtual yarp::dev::ReturnValue setFPSDC1394RPC(const std::int32_t fps)
virtual IFrameGrabberControlDC1394Msgs_return_getTransmissionDC1394 getTransmissionDC1394RPC()
virtual yarp::dev::ReturnValue setPowerDC1394RPC(const bool onoff)
virtual IFrameGrabberControlDC1394Msgs_return_getISOSpeedDC1394 getISOSpeedDC1394RPC()
virtual IFrameGrabberControlMsgs_return_getFeature2 getFeature2RPC(const std::int32_t feature)
virtual IFrameGrabberControlMsgs_return_hasFeature hasFeatureRPC(const std::int32_t feature)
virtual yarp::dev::ReturnValue setTransmissionDC1394RPC(const bool bTxON)
virtual IFrameGrabberControlMsgs_return_getFeature1 getFeature1RPC(const std::int32_t feature)
virtual IFrameGrabberControlMsgs_return_getCameraDescription getCameraDescriptionRPC()
virtual yarp::dev::ReturnValue setRgbResolutionRPC(const std::int32_t width, const std::int32_t height)
virtual yarp::dev::ReturnValue setDefaultsDC1394RPC()
virtual IRGBVisualParamsMsgs_return_getRgbResolution getRgbResolutionRPC()
virtual IFrameGrabberControlDC1394Msgs_return_getFPSMaskDC1394 getFPSMaskDC1394RPC()
virtual IFrameGrabberControlDC1394Msgs_return_getVideoModeMaskDC1394 getVideoModeMaskDC1394RPC()
virtual IFrameGrabberControlDC1394Msgs_return_getColorCodingMaskDC1394 getColorCodingMaskDC1394RPC(const std::int32_t videomode)
virtual yarp::dev::ReturnValue setOperationModeDC1394RPC(const bool b1394b)
virtual IRGBVisualParamsMsgs_return_getRgbSupportedCfg getRgbSupportedConfigurationsRPC()
virtual yarp::dev::ReturnValue setISOSpeedDC1394RPC(const std::int32_t speed)
virtual IFrameGrabberControlDC1394Msgs_return_getFPSDC1394 getFPSDC1394RPC()
virtual yarp::dev::ReturnValue setCaptureDC1394RPC(const bool bON)
virtual IFrameGrabberControlMsgs_return_hasAuto hasAutoRPC(const std::int32_t feature)
virtual IRGBVisualParamsMsgs_return_getRgbMirroring getRgbMirroringRPC()
virtual IRGBVisualParamsMsgs_return_getRgbFOV getRgbFOVRPC()
virtual yarp::dev::ReturnValue setFeature1RPC(const std::int32_t feature, const double value)
virtual IFrameGrabberControlMsgs_return_getMode getModeRPC(const std::int32_t feature)
virtual IRGBVisualParamsMsgs_return_getRgbIntrinsicParam getRgbIntrinsicParamRPC()
virtual IRGBVisualParamsMsgs_return_getRgbWidth getRgbWidthRPC()
virtual yarp::dev::ReturnValue setRgbMirroringRPC(const bool mirror)
virtual IFrameGrabberControlDC1394Msgs_return_getVideoModeDC1394 getVideoModeDC1394RPC()
virtual yarp::dev::ReturnValue setBroadcastDC1394RPC(const bool onoff)
virtual IFrameGrabberControlDC1394Msgs_return_getColorCodingDC1394 getColorCodingDC1394RPC()
virtual yarp::dev::ReturnValue setResetDC1394RPC()
virtual IFrameGrabberControlMsgs_return_hasOnOff hasOnOffRPC(const std::int32_t feature)
virtual IFrameGrabberControlDC1394Msgs_return_getFormat7WindowDC1394 getFormat7WindowDC1394RPC()
virtual IFrameGrabberControlMsgs_return_hasManual hasManualRPC(const std::int32_t feature)
virtual IFrameGrabberControlMsgs_return_hasOnePush hasOnePushRPC(const std::int32_t feature)
virtual IFrameGrabberControlDC1394Msgs_return_getBytesPerPacketDC1394 getBytesPerPacketDC1394RPC()
virtual yarp::dev::ReturnValue setModeRPC(const std::int32_t feature, const yarp::dev::FeatureMode mode)
virtual yarp::dev::ReturnValue setActiveRPC(const std::int32_t feature, const bool onoff)
FrameGrabberOf_ForwarderWithStream(FrameGrabberMsgs *thriftClient)
void setStreamReceiver(StreamReceiver *m_streamReceiver)
yarp::dev::ReturnValue getImage(ImageType &image) override
Get an image from the frame grabber.
int width() const override
Return the width of each frame.
yarp::dev::ReturnValue getImageCrop(yarp::dev::cropType_id_t cropType, std::vector< yarp::dev::vertex_t > vertices, ImageType &image) override
Get a crop of the image from the frame grabber.
int height() const override
Return the height of each frame.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
yarp::dev::ReturnValue getColorCodingDC1394(unsigned int &val) override
yarp::dev::ReturnValue setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
yarp::dev::ReturnValue getRgbSupportedConfigurations(std::vector< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
yarp::dev::ReturnValue setMode(yarp::dev::cameraFeature_id_t feature, yarp::dev::FeatureMode mode) override
Set the requested mode for the feature.
yarp::dev::ReturnValue getCameraDescription(yarp::dev::CameraDescriptor &camera) override
Get a basic description of the camera hw.
yarp::dev::ReturnValue getColorCodingMaskDC1394(unsigned int video_mode, unsigned int &val) override
yarp::dev::ReturnValue getISOSpeedDC1394(unsigned int &val) override
yarp::dev::ReturnValue setBroadcastDC1394(bool onoff) override
yarp::dev::ReturnValue getFormat7WindowDC1394(unsigned int &xdim, unsigned int &ydim, int &x0, int &y0) override
yarp::dev::ReturnValue setCaptureDC1394(bool bON) override
yarp::dev::ReturnValue getFPSMaskDC1394(unsigned int &val) override
yarp::dev::ReturnValue setColorCodingDC1394(int coding) override
yarp::dev::ReturnValue getFormat7MaxWindowDC1394(unsigned int &xdim, unsigned int &ydim, unsigned int &xstep, unsigned int &ystep, unsigned int &xoffstep, unsigned int &yoffstep) override
yarp::dev::ReturnValue getOperationModeDC1394(bool &b1394b) override
yarp::dev::ReturnValue setISOSpeedDC1394(int speed) override
yarp::dev::ReturnValue setBytesPerPacketDC1394(unsigned int bpp) override
yarp::dev::ReturnValue setVideoModeDC1394(int video_mode) override
yarp::dev::ReturnValue getMode(yarp::dev::cameraFeature_id_t feature, yarp::dev::FeatureMode &mode) override
Get the current mode for the feature.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue setDefaultsDC1394() override
yarp::dev::ReturnValue hasFeature(yarp::dev::cameraFeature_id_t feature, bool &hasFeature) override
Check if camera has the requested feature (saturation, brightness ... )
yarp::dev::ReturnValue setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
int getRgbWidth() override
Return the width of each frame.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue getTransmissionDC1394(bool &bTxON) override
yarp::dev::ReturnValue getVideoModeMaskDC1394(unsigned int &val) override
yarp::dev::ReturnValue getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
yarp::dev::ReturnValue hasAuto(yarp::dev::cameraFeature_id_t feature, bool &hasAuto) override
Check if the requested feature has the 'auto' mode.
int getRgbHeight() override
Return the height of each frame.
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
yarp::dev::ReturnValue getFPSDC1394(unsigned int &val) override
yarp::dev::ReturnValue setTransmissionDC1394(bool bTxON) override
yarp::dev::ReturnValue getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
yarp::dev::ReturnValue setPowerDC1394(bool onoff) override
yarp::dev::ReturnValue hasOnePush(yarp::dev::cameraFeature_id_t feature, bool &hasOnePush) override
Check if the requested feature has the 'onePush' mode.
yarp::dev::ReturnValue hasOnOff(yarp::dev::cameraFeature_id_t feature, bool &HasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
yarp::dev::ReturnValue setFPSDC1394(int fps) override
yarp::dev::ReturnValue getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
yarp::dev::ReturnValue setFeature(yarp::dev::cameraFeature_id_t feature, double value) override
Set the requested feature to a value (saturation, brightness ... )
yarp::dev::ReturnValue setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
yarp::dev::ReturnValue getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
yarp::dev::ReturnValue getVideoModeDC1394(unsigned int &val) override
yarp::dev::ReturnValue getFeature(yarp::dev::cameraFeature_id_t feature, double &value) override
Get the current value for the requested feature.
yarp::dev::ReturnValue getActive(yarp::dev::cameraFeature_id_t feature, bool &isActive) override
Get the current status of the feature, on or off.
yarp::dev::ReturnValue getBytesPerPacketDC1394(unsigned int &bpp) override
yarp::dev::ReturnValue setOnePush(yarp::dev::cameraFeature_id_t feature) override
Set the requested feature to a value (saturation, brightness ... )
yarp::dev::ReturnValue setFormat7WindowDC1394(unsigned int xdim, unsigned int ydim, int x0, int y0) override
yarp::dev::ReturnValue setActive(yarp::dev::cameraFeature_id_t feature, bool onoff) override
Set the requested feature on or off.
yarp::dev::ReturnValue setOperationModeDC1394(bool b1394b) override
yarp::dev::ReturnValue setResetDC1394() override
yarp::dev::ReturnValue hasManual(yarp::dev::cameraFeature_id_t feature, bool &hasManual) override
Check if the requested feature has the 'manual' mode.
yarp::dev::FeatureMode mode
std::vector< yarp::dev::CameraConfig > configuration
yarp::os::Stamp lastStamp() const
bool open(const std::string &local, const std::string &remote, const std::string &carrier)
A mini-server for performing network communication in the background.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
A base class for nested structures that can be searched.
An abstraction for a time stamp and/or sequence number.
A single value (typically within a Bottle).
bool attachAsClient(yarp::os::UnbufferedContactable &port)
Tag this WireLink as a client, sending data via the specified port.
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Image class with user control of representation details.
size_t width() const
Gets width of image in pixels.
size_t height() const
Gets height of image in pixels.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
bool cropRect(const yarp::sig::Image &inImg, const std::pair< unsigned int, unsigned int > &vertex1, const std::pair< unsigned int, unsigned int > &vertex2, yarp::sig::Image &outImg)
Crop a rectangle area out of an image given two opposite vertices.
The main, catch-all namespace for YARP.
std::string deviceDescription