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>
9#include <yarp/dev/IWrapper.h>
10
11#include <catch2/catch_amalgamated.hpp>
12#include <harness.h>
13
14using namespace yarp::os;
15using namespace yarp::dev;
16using namespace yarp::sig;
17
18
19TEST_CASE("dev::frameGrabberCropperTest", "[yarp::dev]")
20{
21 YARP_REQUIRE_PLUGIN("fakeFrameGrabber", "device");
22 YARP_REQUIRE_PLUGIN("frameGrabberCropper", "device");
23
24 Network::setLocalMode(true);
25
26 SECTION("test the frameGrabberCropper mode")
27 {
28 constexpr size_t width = 320;
29 constexpr size_t height = 240;
30
31 // Open fakeFrameGrabber
32 PolyDriver dd;
33 Property p;
34 p.put("device", "fakeFrameGrabber");
35 p.put("width", static_cast<int>(width * 2));
36 p.put("height", static_cast<int>(height));
37 REQUIRE(dd.open(p));
38
39 // Open frameGrabberCropper left
42 pl.put("device","frameGrabberCropper");
43 pl.put("x1", 0);
44 pl.put("y1", 0);
45 pl.put("x2", static_cast<int>(width - 1));
46 pl.put("y2", static_cast<int>(height - 1));
48
49 // Attach frameGrabberCropper left
50 yarp::dev::IWrapper* wl = nullptr;
51 REQUIRE(ddl.view(wl));
52 REQUIRE(wl);
53 REQUIRE(wl->attach(&dd));
54
55 // Check IFrameGrabberImage on frameGrabberCropper left
56 IFrameGrabberImage *ifgil = nullptr;
57 REQUIRE(ddl.view(ifgil));
59
61 ifgil->getImage(imgl);
62 CHECK(imgl.width() == width);
63 CHECK(imgl.height() == height);
64
65
66 // Open frameGrabberCropper right
69 pr.put("device","frameGrabberCropper");
70 pr.put("x1", static_cast<int>(width));
71 pr.put("y1", static_cast<int>(0));
72 pr.put("x2", static_cast<int>((width * 2) - 1));
73 pr.put("y2", static_cast<int>(height - 1));
75
76 // Attach frameGrabberCropper right
77 yarp::dev::IWrapper* wr = nullptr;
78 REQUIRE(ddr.view(wr));
79 REQUIRE(wr);
80 REQUIRE(wr->attach(&dd));
81
82 // Check IFrameGrabberImage on frameGrabberCropper right
83 IFrameGrabberImage *ifgir = nullptr;
84 REQUIRE(ddr.view(ifgir));
86
88 ifgir->getImage(imgr);
89 CHECK(imgr.width() == width);
90 CHECK(imgr.height() == height);
91
92
93 // Close all devices
94 CHECK(ddl.close());
95 CHECK(ddr.close());
96 CHECK(dd.close());
97 }
98
99 Network::setLocalMode(false);
100}
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]")
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.