YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IRgbVisualParamsTest.h
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#ifndef IRGBVISUALPARAMSTEST_H
7#define IRGBVISUALPARAMSTEST_H
8
10#include <catch2/catch_amalgamated.hpp>
11
12using namespace yarp::dev;
13using namespace yarp::sig;
14using namespace yarp::os;
15
16namespace yarp::dev::tests
17{
18 const std::vector<yarp::dev::CameraConfig> default_configurations = {
19 { 128, 128, 60.0, VOCAB_PIXEL_RGB },
20 { 256, 256, 30.0, VOCAB_PIXEL_BGR },
21 { 512, 512, 15.0, VOCAB_PIXEL_MONO }
22 };
23
25 {
27
28 // checking getRgbFOV
29 {
30 double hfov = 0.0;
31 double vfov = 0.0;
32 CHECK(irgb->getRgbFOV(hfov, vfov));
33 CHECK(hfov == 1.0);
34 CHECK(vfov == 2.0);
35 }
36
37 // checking height
38 {
39 CHECK(irgb->getRgbHeight() == 240);
40 }
41
42 // checking width
43 {
44 CHECK(irgb->getRgbWidth() == 320);
45 }
46
47 // checking intrinsics
48 {
50 CHECK(irgb->getRgbIntrinsicParam(intrinsics));
51 CHECK(intrinsics.find("focalLengthX").asFloat64() == 4.0); // checking focalLength X
52 CHECK(intrinsics.find("focalLengthY").asFloat64() == 5.0); // checking focalLength Y
53 CHECK(intrinsics.find("principalPointX").asFloat64() == 6.0); // checking principalPoint X
54 CHECK(intrinsics.find("principalPointY").asFloat64() == 7.0); // checking principalPoint Y
55 CHECK(intrinsics.find("k1").asFloat64() == 8.0); // checking k1
56 CHECK(intrinsics.find("k2").asFloat64() == 9.0); // checking k2
57 CHECK(intrinsics.find("k3").asFloat64() == 10.0); // checking k3
58 CHECK(intrinsics.find("t1").asFloat64() == 11.0); // checking t1
59 CHECK(intrinsics.find("t2").asFloat64() == 12.0); // checking t2
60 CHECK(intrinsics.find("distortionModel").asString() == "FishEye"); // checking distorionModel
61
62 // checking the rectificationMatrix
63 yarp::os::Bottle* retM = nullptr;
64 retM = intrinsics.find("rectificationMatrix").asList();
65 double data[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
66 Vector v(9, data);
67 Vector v2;
68 REQUIRE(retM); // segfault otherwise
69 std::string retM_string = retM->toString();
71 REQUIRE((cpret && v2.size() == 9)); // Otherwise the following loop will segfault
72 for (int i = 0; i < 3; i++)
73 {
74 for (int j = 0; j < 3; j++)
75 {
76 CHECK(retM->get(i * 3 + j).asFloat64() == v(i * 3 + j));
77 CHECK(v2(i * 3 + j) == v(i * 3 + j));
78 }
79 }
80 }
81
82 // checking getRgbMirroring
83 {
84 bool rgbMirroring = true;
85 CHECK(irgb->getRgbMirroring(rgbMirroring));
87 }
88
89 // checking getRgbResolution
90 {
91 int height = 0;
92 int width = 0;
93 CHECK(irgb->getRgbResolution(width, height));
94 CHECK(width == 320);
95 CHECK(height == 240);
96 }
97
98 // checking configurations size
99 {
100 std::vector<CameraConfig> configurations;
101 CHECK(irgb->getRgbSupportedConfigurations(configurations));
102 CHECK(configurations.size() == 3);
103
104 // checking first supported configuration
105 CHECK(configurations[0].height == 128);
106 CHECK(configurations[0].width == 128);
107 CHECK(configurations[0].framerate == 60.0);
108 CHECK(configurations[0].pixelCoding == VOCAB_PIXEL_RGB);
109
110 // checking second supported configuration
111 CHECK(configurations[1].height == 256);
112 CHECK(configurations[1].width == 256);
113 CHECK(configurations[1].framerate == 30.0);
114 CHECK(configurations[1].pixelCoding == VOCAB_PIXEL_BGR);
115
116 // checking third supported configuration
117 CHECK(configurations[2].height == 512);
118 CHECK(configurations[2].width == 512);
119 CHECK(configurations[2].framerate == 15.0);
120 CHECK(configurations[2].pixelCoding == VOCAB_PIXEL_MONO);
121 }
122
123 // checking setRgbFOV
124 {
125 double hfov = 0.0;
126 double vfov = 0.0;
127 CHECK(irgb->setRgbFOV(3.0, 4.0));
128 CHECK(irgb->getRgbFOV(hfov, vfov));
129 CHECK(hfov == 3.0);
130 CHECK(vfov == 4.0);
131 }
132
133 // checking setRgbMirroring
134 {
135 bool rgbMirroring=true;
136 CHECK(irgb->setRgbMirroring(rgbMirroring));
138 }
139
140 // checking setRgbResolution
141 {
142 int height = 0;
143 int width = 0;
144 CHECK(irgb->setRgbResolution(101, 102));
145 CHECK(irgb->getRgbResolution(width, height));
146 CHECK(width == 101);
147 CHECK(height == 102);
148 }
149 }
150}
151
152#endif
@ VOCAB_PIXEL_BGR
Definition Image.h:49
@ VOCAB_PIXEL_MONO
Definition Image.h:42
@ VOCAB_PIXEL_RGB
Definition Image.h:44
An interface for retrieving intrinsic parameter from a rgb camera.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
A mini-server for performing network communication in the background.
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition Portable.cpp:16
A class for storing options and configuration information.
Definition Property.h:33
const std::vector< yarp::dev::CameraConfig > default_configurations
void exec_IRgbVisualParams_test_1(IRgbVisualParams *irgb)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
constexpr char framerate[]