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.focalLengthX == 4.0); // checking focalLength X
52 CHECK(intrinsics.focalLengthY == 5.0); // checking focalLength Y
53 CHECK(intrinsics.principalPointX == 6.0); // checking principalPoint X
54 CHECK(intrinsics.principalPointY == 7.0); // checking principalPoint Y
55 CHECK(intrinsics.distortionModel.k1 == 8.0); // checking k1
56 CHECK(intrinsics.distortionModel.k2 == 9.0); // checking k2
57 CHECK(intrinsics.distortionModel.k3 == 10.0); // checking k3
58 CHECK(intrinsics.distortionModel.t1 == 11.0); // checking t1
59 CHECK(intrinsics.distortionModel.t2 == 12.0); // checking t2
60 CHECK(intrinsics.distortionModel.type == CameraDistortionType::YARP_FISH_EYE); // checking distorionModel
61
62 double data[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
63 REQUIRE(intrinsics.rectificationMatrix3X3.size() == 9);
64 for (int i = 0; i < 9; i++)
65 {
66 CHECK(intrinsics.rectificationMatrix3X3[i] == data[i]);
67 }
68 }
69
70 // checking getRgbMirroring
71 {
72 bool rgbMirroring = true;
73 CHECK(irgb->getRgbMirroring(rgbMirroring));
75 }
76
77 // checking getRgbResolution
78 {
79 int height = 0;
80 int width = 0;
81 CHECK(irgb->getRgbResolution(width, height));
82 CHECK(width == 320);
83 CHECK(height == 240);
84 }
85
86 // checking configurations size
87 {
88 std::vector<CameraConfig> configurations;
89 CHECK(irgb->getRgbSupportedConfigurations(configurations));
90 CHECK(configurations.size() == 3);
91
92 // checking first supported configuration
93 CHECK(configurations[0].height == 128);
94 CHECK(configurations[0].width == 128);
95 CHECK(configurations[0].framerate == 60.0);
96 CHECK(configurations[0].pixelCoding == VOCAB_PIXEL_RGB);
97
98 // checking second supported configuration
99 CHECK(configurations[1].height == 256);
100 CHECK(configurations[1].width == 256);
101 CHECK(configurations[1].framerate == 30.0);
102 CHECK(configurations[1].pixelCoding == VOCAB_PIXEL_BGR);
103
104 // checking third supported configuration
105 CHECK(configurations[2].height == 512);
106 CHECK(configurations[2].width == 512);
107 CHECK(configurations[2].framerate == 15.0);
108 CHECK(configurations[2].pixelCoding == VOCAB_PIXEL_MONO);
109 }
110
111 // checking setRgbFOV
112 {
113 double hfov = 0.0;
114 double vfov = 0.0;
115 CHECK(irgb->setRgbFOV(3.0, 4.0));
116 CHECK(irgb->getRgbFOV(hfov, vfov));
117 CHECK(hfov == 3.0);
118 CHECK(vfov == 4.0);
119 }
120
121 // checking setRgbMirroring
122 {
123 bool rgbMirroring=true;
124 CHECK(irgb->setRgbMirroring(rgbMirroring));
126 }
127
128 // checking setRgbResolution
129 {
130 int height = 0;
131 int width = 0;
132 CHECK(irgb->setRgbResolution(101, 102));
133 CHECK(irgb->getRgbResolution(width, height));
134 CHECK(width == 101);
135 CHECK(height == 102);
136 }
137 }
138}
139
140#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 mini-server for performing network communication in the background.
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[]
The IntrinsicParams struct to handle the intrinsic parameter of cameras(RGB and RGBD either).