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
20
21#include <catch2/catch_amalgamated.hpp>
22#include <harness.h>
23
24using namespace yarp::os;
25using namespace yarp::dev;
26using namespace yarp::sig;
27
28
29TEST_CASE("dev::frameGrabberCropperTest", "[yarp::dev]")
30{
31 YARP_REQUIRE_PLUGIN("fakeFrameGrabber", "device");
32 YARP_REQUIRE_PLUGIN("frameGrabberCropper", "device");
33
34 Network::setLocalMode(true);
35
36 SECTION("test the frameGrabberCropper mode")
37 {
38 constexpr size_t width = 320;
39 constexpr size_t height = 240;
40
41 // Open fakeFrameGrabber
42 PolyDriver dd;
43 Property p;
44 p.put("device", "fakeFrameGrabber");
45 p.put("width", static_cast<int>(width * 2));
46 p.put("height", static_cast<int>(height));
47 REQUIRE(dd.open(p));
48
49 // Open frameGrabberCropper left
52 pl.put("device","frameGrabberCropper");
53 pl.put("x1", 0);
54 pl.put("y1", 0);
55 pl.put("x2", static_cast<int>(width - 1));
56 pl.put("y2", static_cast<int>(height - 1));
58
59 // Attach frameGrabberCropper left
60 yarp::dev::IWrapper* wl = nullptr;
61 REQUIRE(ddl.view(wl));
62 REQUIRE(wl);
63 REQUIRE(wl->attach(&dd));
64
65 // Check IFrameGrabberImage on frameGrabberCropper left
66 IFrameGrabberImage *ifgil = nullptr;
67 REQUIRE(ddl.view(ifgil));
69
71 ifgil->getImage(imgl);
72 CHECK(imgl.width() == width);
73 CHECK(imgl.height() == height);
74
75
76 // Open frameGrabberCropper right
79 pr.put("device","frameGrabberCropper");
80 pr.put("x1", static_cast<int>(width));
81 pr.put("y1", static_cast<int>(0));
82 pr.put("x2", static_cast<int>((width * 2) - 1));
83 pr.put("y2", static_cast<int>(height - 1));
86
87 // Attach frameGrabberCropper right
88 yarp::dev::IWrapper* wr = nullptr;
89 REQUIRE(ddr.view(wr));
90 REQUIRE(wr);
91 REQUIRE(wr->attach(&dd));
92
93 // Check IFrameGrabberImage on frameGrabberCropper right
94 IFrameGrabberImage *ifgir = nullptr;
95 REQUIRE(ddr.view(ifgir));
97
99 ifgir->getImage(imgr);
100 CHECK(imgr.width() == width);
101 CHECK(imgr.height() == height);
102
103
104 // Close all devices
105 CHECK(ddl.close());
106 CHECK(ddr.close());
107 CHECK(dd.close());
108 }
109
110 SECTION("test the frameGrabberCropper control")
111 {
112 constexpr size_t width = 320;
113 constexpr size_t height = 240;
114
115 // Open fakeFrameGrabber
116 PolyDriver dd;
117 Property p;
118 p.put("device", "fakeFrameGrabber");
119 p.put("width", static_cast<int>(width));
120 p.put("height", static_cast<int>(height));
121 REQUIRE(dd.open(p));
122
123 // Open frameGrabberCropper left
125 Property pl;
126 pl.put("device","frameGrabberCropper");
127 pl.put("x1", 0);
128 pl.put("y1", 0);
129 pl.put("x2", static_cast<int>(width - 1));
130 pl.put("y2", static_cast<int>(height - 1));
131 REQUIRE(ddl.open(pl));
132
133 // Attach frameGrabberCropper left
134 yarp::dev::IWrapper* wl = nullptr;
135 REQUIRE(ddl.view(wl));
136 REQUIRE(wl);
137 REQUIRE(wl->attach(&dd));
138
139 IFrameGrabberImage *ifgi = nullptr;
140 REQUIRE(ddl.view(ifgi));
141 IRgbVisualParams* rgbParams = nullptr;
143 IFrameGrabberControls* ictl = nullptr;
144 REQUIRE(dd.view(ictl));
146 REQUIRE(dd.view(ictl1394));
147
152
153 // Close all devices
154 CHECK(ddl.close());
155 CHECK(dd.close());
156 }
157
158 Network::setLocalMode(false);
159}
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_params_test(yarp::dev::PolyDriver *pdrv)
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.
Definition OSTestMsg.cpp:13