Skip to content

Commit cf3e538

Browse files
committed
Resolve YARP 3.5 deprecations regarding FrameGrabberInterfaces.h
1 parent f87fbd1 commit cf3e538

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

examples/cpp/exampleRemoteGrabber/exampleRemoteGrabber.cpp

+30-22
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,42 @@
66
* @brief This example connects to a remote grabber (generally, RGB) device.
77
*/
88

9-
#include <cstdio>
9+
#include <yarp/conf/version.h>
1010

11+
#include <yarp/os/LogStream.h>
1112
#include <yarp/os/Network.h>
1213
#include <yarp/os/Property.h>
1314

1415
#include <yarp/dev/PolyDriver.h>
15-
#include <yarp/dev/FrameGrabberInterfaces.h>
16+
17+
#if YARP_VERSION_MINOR >= 5
18+
# include <yarp/dev/IFrameGrabberImage.h>
19+
# include <yarp/dev/IFrameGrabberControls.h>
20+
#else
21+
# include <yarp/dev/FrameGrabberInterfaces.h>
22+
#endif
1623

1724
int main(int argc, char *argv[])
1825
{
1926
yarp::os::Network yarp;
2027

2128
if (!yarp::os::Network::checkNetwork())
2229
{
23-
std::printf("Please start a yarp name server first\n");
30+
yError() << "Please start a yarp name server first";
2431
return 1;
2532
}
2633

27-
yarp::os::Property options;
28-
29-
options.put("device","remote_grabber");
30-
options.put("local","/exampleRemoteGrabber");
31-
options.put("remote","/grabber");
34+
yarp::os::Property options {
35+
{"device", yarp::os::Value("remote_grabber")},
36+
{"local", yarp::os::Value("/exampleRemoteGrabber")},
37+
{"remote", yarp::os::Value("/grabber")},
38+
};
3239

3340
yarp::dev::PolyDriver dd(options);
3441

3542
if (!dd.isValid())
3643
{
37-
std::printf("Device not available.\n");
44+
yError() << "Device not available";
3845
return 1;
3946
}
4047

@@ -43,44 +50,45 @@ int main(int argc, char *argv[])
4350

4451
if (!dd.view(iFrameGrabberImage))
4552
{
46-
std::printf("[error] Problems acquiring image interface\n");
53+
yError() << "Problems acquiring image interface";
4754
return 1;
4855
}
56+
4957
if (!dd.view(iFrameGrabberControls))
5058
{
51-
std::printf("[error] Problems acquiring controls interface\n");
59+
yError() << "Problems acquiring controls interface";
5260
return 1;
5361
}
5462

55-
std::printf("[success] acquired interfaces\n");
56-
5763
bool has;
58-
if(iFrameGrabberControls->hasFeature(YARP_FEATURE_ZOOM, &has))
64+
65+
if (iFrameGrabberControls->hasFeature(YARP_FEATURE_ZOOM, &has))
5966
{
60-
if(has)
67+
if (has)
6168
{
6269
double val;
6370
iFrameGrabberControls->getFeature(YARP_FEATURE_ZOOM, &val);
64-
printf("Zoom feature: %f\n", val);
71+
yInfo() << "Zoom feature:" << val;
6572
}
6673
else
67-
printf("Zoom feature: not supported\n");
74+
yInfo() << "Zoom feature: not supported";
6875
}
6976
else
70-
printf("Fail: iFrameGrabberControls->hasFeature\n");
77+
yWarning() << "iFrameGrabberControls->hasFeature() failed";
7178

7279
// The following delay should avoid bad status
7380
yarp::os::Time::delay(1);
7481

7582
yarp::sig::ImageOf<yarp::sig::PixelRgb> image;
76-
if(!iFrameGrabberImage->getImage(image))
83+
84+
if (!iFrameGrabberImage->getImage(image))
7785
{
78-
std::printf("[error] Problems getting image\n");
86+
yError() << "Problems getting image";
7987
return 1;
8088
}
8189

82-
std::printf("Width: %d\n", iFrameGrabberImage->width());
83-
std::printf("Height: %d\n", iFrameGrabberImage->height());
90+
yInfo() << "Width:" << iFrameGrabberImage->width();
91+
yInfo() << "Height:" << iFrameGrabberImage->height();
8492

8593
dd.close();
8694

programs/rgbDetection/RgbDetection.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
#ifndef __RGB_DETECTION_HPP__
44
#define __RGB_DETECTION_HPP__
55

6+
#include <yarp/conf/version.h>
7+
68
#include <yarp/os/Bottle.h>
79
#include <yarp/os/BufferedPort.h>
810
#include <yarp/os/RFModule.h>
911

1012
#include <yarp/dev/PolyDriver.h>
11-
#include <yarp/dev/FrameGrabberInterfaces.h>
13+
14+
#if YARP_VERSION_MINOR >= 5
15+
# include <yarp/dev/IFrameGrabberImage.h>
16+
#else
17+
# include <yarp/dev/FrameGrabberInterfaces.h>
18+
#endif
1219

1320
#include <yarp/sig/Image.h>
1421

0 commit comments

Comments
 (0)