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 {
26 // check the default parameters
27
28 // checking fov
29 double hfov = 0.0;
30 double vfov = 0.0;
31 irgb->getRgbFOV(hfov, vfov);
32 CHECK(hfov == 1.0);
33 CHECK(vfov == 2.0);
34
35 // checking height
36 CHECK(irgb->getRgbHeight() == 240);
37
38 // checking width
39 CHECK(irgb->getRgbWidth() == 320);
40
41 // checking mirroring
42 bool rgbMirroring;
43 irgb->getRgbMirroring(rgbMirroring);
45
46 // checking intrinsics
48 irgb->getRgbIntrinsicParam(intrinsics);
49 CHECK(intrinsics.find("focalLengthX").asFloat64() == 4.0); // checking focalLength X
50 CHECK(intrinsics.find("focalLengthY").asFloat64() == 5.0); // checking focalLength Y
51 CHECK(intrinsics.find("principalPointX").asFloat64() == 6.0); // checking principalPoint X
52 CHECK(intrinsics.find("principalPointY").asFloat64() == 7.0); // checking principalPoint Y
53 CHECK(intrinsics.find("k1").asFloat64() == 8.0); // checking k1
54 CHECK(intrinsics.find("k2").asFloat64() == 9.0); // checking k2
55 CHECK(intrinsics.find("k3").asFloat64() == 10.0); // checking k3
56 CHECK(intrinsics.find("t1").asFloat64() == 11.0); // checking t1
57 CHECK(intrinsics.find("t2").asFloat64() == 12.0); // checking t2
58 CHECK(intrinsics.find("distortionModel").asString() == "FishEye"); // checking distorionModel
59
60 // checking the rectificationMatrix
61 yarp::os::Bottle* retM = nullptr;
62 retM = intrinsics.find("rectificationMatrix").asList();
63 double data[9] = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 };
64 Vector v(9, data);
65 Vector v2;
66 std::string retM_string = retM->toString();
68 REQUIRE ((cpret && v2.size()==9)); //Otherwise the following loop will segfault
69 for (int i = 0; i < 3; i++) {
70 for (int j = 0; j < 3; j++) {
71 CHECK(retM->get(i * 3 + j).asFloat64() == v(i * 3 + j));
72 CHECK(v2(i * 3 + j) == v(i * 3 + j));
73 }
74 }
75
76 // checking getRgbResolution
77 int height, width;
78 irgb->getRgbResolution(width, height);
79 CHECK(width == 320);
80 CHECK(height == 240);
81
82 // checking configurations size
83 VectorOf<CameraConfig> configurations;
84 CHECK(irgb->getRgbSupportedConfigurations(configurations));
85 CHECK(configurations.size() == 3);
86
87 // checking first supported configuration
88 CHECK(configurations[0].height == 128);
89 CHECK(configurations[0].width == 128);
90 CHECK(configurations[0].framerate == 60.0);
91 CHECK(configurations[0].pixelCoding == VOCAB_PIXEL_RGB);
92
93 // checking second supported configuration
94 CHECK(configurations[1].height == 256);
95 CHECK(configurations[1].width == 256);
96 CHECK(configurations[1].framerate == 30.0);
97 CHECK(configurations[1].pixelCoding == VOCAB_PIXEL_BGR);
98
99 // checking third supported configuration
100 CHECK(configurations[2].height == 512);
101 CHECK(configurations[2].width == 512);
102 CHECK(configurations[2].framerate == 15.0);
103 CHECK(configurations[2].pixelCoding == VOCAB_PIXEL_MONO);
104 }
105}
106
107#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:64
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[]