YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
frameGrabberCropper_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/sig/Image.h>
8#include <yarp/dev/IWrapper.h>
9
14
19
20#include <catch2/catch_amalgamated.hpp>
21#include <harness.h>
22
23using namespace yarp::os;
24using namespace yarp::dev;
25using namespace yarp::sig;
26
27
28TEST_CASE("dev::frameGrabberCropperTest", "[yarp::dev]")
29{
30 YARP_REQUIRE_PLUGIN("fakeFrameGrabber", "device");
31 YARP_REQUIRE_PLUGIN("frameGrabberCropper", "device");
32
33 Network::setLocalMode(true);
34
35 SECTION("test the frameGrabberCropper mode")
36 {
37 constexpr size_t width = 320;
38 constexpr size_t height = 240;
39
40 // Open fakeFrameGrabber
41 PolyDriver dd;
42 Property p;
43 p.put("device", "fakeFrameGrabber");
44 p.put("width", static_cast<int>(width * 2));
45 p.put("height", static_cast<int>(height));
46 REQUIRE(dd.open(p));
47
48 // Open frameGrabberCropper left
51 pl.put("device","frameGrabberCropper");
52 pl.put("x1", 0);
53 pl.put("y1", 0);
54 pl.put("x2", static_cast<int>(width - 1));
55 pl.put("y2", static_cast<int>(height - 1));
57
58 // Attach frameGrabberCropper left
59 yarp::dev::IWrapper* wl = nullptr;
60 REQUIRE(ddl.view(wl));
61 REQUIRE(wl);
62 REQUIRE(wl->attach(&dd));
63
64 // Check IFrameGrabberImage on frameGrabberCropper left
65 IFrameGrabberImage *ifgil = nullptr;
66 REQUIRE(ddl.view(ifgil));
68
70 ifgil->getImage(imgl);
71 CHECK(imgl.width() == width);
72 CHECK(imgl.height() == height);
73
74
75 // Open frameGrabberCropper right
78 pr.put("device","frameGrabberCropper");
79 pr.put("x1", static_cast<int>(width));
80 pr.put("y1", static_cast<int>(0));
81 pr.put("x2", static_cast<int>((width * 2) - 1));
82 pr.put("y2", static_cast<int>(height - 1));
84
85 // Attach frameGrabberCropper right
86 yarp::dev::IWrapper* wr = nullptr;
87 REQUIRE(ddr.view(wr));
88 REQUIRE(wr);
89 REQUIRE(wr->attach(&dd));
90
91 // Check IFrameGrabberImage on frameGrabberCropper right
92 IFrameGrabberImage *ifgir = nullptr;
93 REQUIRE(ddr.view(ifgir));
95
97 ifgir->getImage(imgr);
98 CHECK(imgr.width() == width);
99 CHECK(imgr.height() == height);
100
101
102 // Close all devices
103 CHECK(ddl.close());
104 CHECK(ddr.close());
105 CHECK(dd.close());
106 }
107
108 SECTION("test the frameGrabberCropper control")
109 {
110 constexpr size_t width = 320;
111 constexpr size_t height = 240;
112
113 // Open fakeFrameGrabber
114 PolyDriver dd;
115 Property p;
116 p.put("device", "fakeFrameGrabber");
117 p.put("width", static_cast<int>(width));
118 p.put("height", static_cast<int>(height));
119 REQUIRE(dd.open(p));
120
121 // Open frameGrabberCropper left
123 Property pl;
124 pl.put("device","frameGrabberCropper");
125 pl.put("x1", 0);
126 pl.put("y1", 0);
127 pl.put("x2", static_cast<int>(width - 1));
128 pl.put("y2", static_cast<int>(height - 1));
129 REQUIRE(ddl.open(pl));
130
131 // Attach frameGrabberCropper left
132 yarp::dev::IWrapper* wl = nullptr;
133 REQUIRE(ddl.view(wl));
134 REQUIRE(wl);
135 REQUIRE(wl->attach(&dd));
136
137 IFrameGrabberImage *ifgi = nullptr;
138 REQUIRE(ddl.view(ifgi));
139 IRgbVisualParams* rgbParams = nullptr;
141 IFrameGrabberControls* ictl = nullptr;
142 REQUIRE(dd.view(ictl));
144 REQUIRE(dd.view(ictl1394));
145
150
151 // Close all devices
152 CHECK(ddl.close());
153 CHECK(dd.close());
154 }
155
156 Network::setLocalMode(false);
157}
bool view(T *&x)
Get an interface to the device driver.
Control interface for frame grabber devices that conform to the 1394-based Digital Camera Specificati...
Control interface for frame grabber devices.
An interface for retrieving intrinsic parameter from a rgb camera.
Interface for an object that can wrap/or "attach" to another.
Definition IWrapper.h:25
A container for a device driver.
Definition PolyDriver.h:23
bool close() override
Close the DeviceDriver.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A mini-server for performing network communication in the background.
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.
Definition Property.h:33
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition Property.cpp:987
TEST_CASE("dev::frameGrabberCropperTest", "[yarp::dev]")
void exec_IFrameGrabberControlsDC1394_test_1(IFrameGrabberControlsDC1394 *ictl)
void exec_IFrameGrabberControls_test_1(IFrameGrabberControls *ictl)
void exec_IRgbVisualParams_test_1(IRgbVisualParams *irgb)
void exec_IFrameGrabberImage_test_1(IFrameGrabberImage *iframe)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.