Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
catchFont.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Test draw text with vpFont.
32
*/
33
39
40
#include <visp3/core/vpConfig.h>
41
42
#if defined(VISP_HAVE_CATCH2)
43
44
#include "common.hpp"
45
#include <catch_amalgamated.hpp>
46
#include <visp3/core/vpFont.h>
47
48
49
#ifdef ENABLE_VISP_NAMESPACE
50
using namespace
VISP_NAMESPACE_NAME
;
51
#endif
52
TEST_CASE(
"Segmentation fault reproducer"
,
"[draw_text_font]"
)
53
{
54
std::ostringstream oss;
55
oss <<
"Computation time: "
<< std::fixed << std::setprecision(2) << 10.5168 <<
" ms/"
;
56
57
SECTION(
"GENERIC_MONOSPACE"
)
58
{
59
vpFont
font(20,
vpFont::GENERIC_MONOSPACE
);
60
61
SECTION(
"unsigned char"
)
62
{
63
REQUIRE_NOTHROW([&]() {
64
vpImage<unsigned char>
I(32, 256);
65
font.drawText(I, oss.str(),
vpImagePoint
(10, 10), 200);
66
}());
67
}
68
69
SECTION(
"vpRGBa"
)
70
{
71
REQUIRE_NOTHROW([&]() {
72
vpImage<vpRGBa>
I(32, 256);
73
font.drawText(I, oss.str(),
vpImagePoint
(10, 10),
vpColor::red
);
74
}());
75
}
76
}
77
78
SECTION(
"TRUETYPE_FILE"
)
79
{
80
vpFont
font(20,
vpFont::TRUETYPE_FILE
);
81
82
SECTION(
"unsigned char"
)
83
{
84
REQUIRE_NOTHROW([&]() {
85
vpImage<unsigned char>
I(32, 256);
86
font.drawText(I, oss.str(),
vpImagePoint
(10, 10), 200);
87
}());
88
}
89
90
SECTION(
"vpRGBa"
)
91
{
92
REQUIRE_NOTHROW([&]() {
93
vpImage<vpRGBa>
I(32, 256);
94
font.drawText(I, oss.str(),
vpImagePoint
(10, 10),
vpColor::red
);
95
}());
96
}
97
}
98
}
99
100
TEST_CASE(
"Sanity check"
,
"[draw_text_font]"
)
101
{
102
const
std::string text =
"ViSP standing for Visual Servoing Platform is a modular cross platform library. "
103
"0123456789 ,;:!?./§ &é'(-è_çà)="
;
104
105
SECTION(
"GENERIC_MONOSPACE"
)
106
{
107
vpFont
font(16,
vpFont::GENERIC_MONOSPACE
);
108
109
SECTION(
"unsigned char"
)
110
{
111
REQUIRE_NOTHROW([&]() {
112
vpImage<unsigned char>
I(32, 512);
113
font.drawText(I, text,
vpImagePoint
(10, 10), 200);
114
}());
115
}
116
117
SECTION(
"vpRGBa"
)
118
{
119
REQUIRE_NOTHROW([&]() {
120
vpImage<vpRGBa>
I(32, 512);
121
font.drawText(I, text,
vpImagePoint
(10, 10),
vpColor::red
);
122
}());
123
}
124
}
125
126
SECTION(
"TRUETYPE_FILE"
)
127
{
128
vpFont
font(16,
vpFont::TRUETYPE_FILE
);
129
130
SECTION(
"unsigned char"
)
131
{
132
REQUIRE_NOTHROW([&]() {
133
vpImage<unsigned char>
I(32, 512);
134
font.drawText(I, text,
vpImagePoint
(10, 10), 200);
135
}());
136
}
137
138
SECTION(
"vpRGBa"
)
139
{
140
REQUIRE_NOTHROW([&]() {
141
vpImage<vpRGBa>
I(32, 512);
142
font.drawText(I, text,
vpImagePoint
(10, 10),
vpColor::red
);
143
}());
144
}
145
}
146
}
147
148
int
main(
int
argc,
char
*argv[])
149
{
150
Catch::Session session;
151
session.applyCommandLine(argc, argv);
152
int
numFailed = session.run();
153
return
numFailed;
154
}
155
#else
156
int
main() {
return
EXIT_SUCCESS; }
157
#endif
vpColor::red
static const vpColor red
Definition
vpColor.h:198
vpFont
Font drawing functions for image.
Definition
vpFont.h:55
vpFont::GENERIC_MONOSPACE
@ GENERIC_MONOSPACE
Definition
vpFont.h:57
vpFont::TRUETYPE_FILE
@ TRUETYPE_FILE
Definition
vpFont.h:57
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
modules
core
test
image
catchFont.cpp
Generated by
1.17.0