Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d77088b1
Commit
d77088b1
authored
Oct 27, 2014
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3336 from BKNio:putText_develop2
parents
67e50b44
b5a6df49
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
19 deletions
+95
-19
drawing.cpp
modules/core/src/drawing.cpp
+17
-19
test_drawing.cpp
modules/highgui/test/test_drawing.cpp
+78
-0
No files found.
modules/core/src/drawing.cpp
View file @
d77088b1
...
@@ -2028,38 +2028,36 @@ inline void readCheck(int &c, int &i, const string &text, int fontFace)
...
@@ -2028,38 +2028,36 @@ inline void readCheck(int &c, int &i, const string &text, int fontFace)
if
(
c
>=
0x80
&&
fontFace
==
FONT_HERSHEY_COMPLEX
)
if
(
c
>=
0x80
&&
fontFace
==
FONT_HERSHEY_COMPLEX
)
{
{
if
(
c
>=
0xC0
&&
c
<=
0xDF
)
//2 bytes utf
if
(
c
==
0xD0
&&
(
uchar
)
text
[
i
+
1
]
>=
0x90
&&
(
uchar
)
text
[
i
+
1
]
<=
0xBF
)
{
{
if
(
c
&
1
)
c
=
(
uchar
)
text
[
++
i
]
-
17
;
{
leftBoundary
=
127
;
c
=
(
uchar
)
text
[
++
i
]
+
47
;
rightBoundary
=
175
;
leftBoundary
=
175
;
}
rightBoundary
=
191
;
else
if
(
c
==
0xD1
&&
(
uchar
)
text
[
i
+
1
]
>=
0x80
&&
(
uchar
)
text
[
i
+
1
]
<=
0x8F
)
}
{
else
c
=
(
uchar
)
text
[
++
i
]
+
47
;
{
leftBoundary
=
175
;
c
=
(
uchar
)
text
[
++
i
]
-
17
;
rightBoundary
=
191
;
leftBoundary
=
127
;
rightBoundary
=
175
;
}
}
}
else
else
{
{
if
(
c
>=
0x
E0
)
//3
bytes utf
if
(
c
>=
0x
C0
&&
text
[
i
+
1
]
!=
0
)
//2
bytes utf
i
++
;
i
++
;
if
(
c
>=
0x
F0
)
//4
bytes utf
if
(
c
>=
0x
E0
&&
text
[
i
+
1
]
!=
0
)
//3
bytes utf
i
++
;
i
++
;
if
(
c
>=
0xF
8
)
//5
bytes utf
if
(
c
>=
0xF
0
&&
text
[
i
+
1
]
!=
0
)
//4
bytes utf
i
++
;
i
++
;
if
(
c
>=
0xF
C
)
//6
bytes utf
if
(
c
>=
0xF
8
&&
text
[
i
+
1
]
!=
0
)
//5
bytes utf
i
++
;
i
++
;
i
++
;
i
f
(
c
>=
0xFC
&&
text
[
i
+
1
]
!=
0
)
//6 bytes utf
c
=
'?'
;
i
++
;
c
=
'?'
;
}
}
}
}
...
...
modules/highgui/test/test_drawing.cpp
View file @
d77088b1
...
@@ -447,3 +447,81 @@ protected:
...
@@ -447,3 +447,81 @@ protected:
};
};
TEST
(
Highgui_Drawing
,
fillconvexpoly_clipping
)
{
CV_FillConvexPolyTest
test
;
test
.
safe_run
();
}
TEST
(
Highgui_Drawing
,
fillconvexpoly_clipping
)
{
CV_FillConvexPolyTest
test
;
test
.
safe_run
();
}
class
CV_DrawingTest_UTF8
:
public
cvtest
::
BaseTest
{
public
:
CV_DrawingTest_UTF8
()
{}
~
CV_DrawingTest_UTF8
()
{}
protected
:
void
run
(
int
)
{
vector
<
string
>
lines
;
lines
.
push_back
(
"abcdefghijklmnopqrstuvwxyz1234567890"
);
// cyrillic letters small
lines
.
push_back
(
"
\xD0\xB0\xD0\xB1\xD0\xB2\xD0\xB3\xD0\xB4\xD0\xB5\xD1\x91\xD0\xB6\xD0\xB7
"
"
\xD0\xB8\xD0\xB9\xD0\xBA\xD0\xBB\xD0\xBC\xD0\xBD\xD0\xBE\xD0\xBF\xD1\x80
"
"
\xD1\x81\xD1\x82\xD1\x83\xD1\x84\xD1\x85\xD1\x86\xD1\x87\xD1\x88\xD1\x89
"
"
\xD1\x8A\xD1\x8B\xD1\x8C\xD1\x8D\xD1\x8E\xD1\x8F
"
);
// cyrillic letters capital
lines
.
push_back
(
"
\xD0\x90\xD0\x91\xD0\x92\xD0\x93\xD0\x94\xD0\x95\xD0\x81\xD0\x96\xD0\x97
"
"
\xD0\x98\xD0\x99\xD0\x9A\xD0\x9B\xD0\x9C\xD0\x9D\xD0\x9E\xD0\x9F\xD0\xA0
"
"
\xD0\xA1\xD0\xA2\xD0\xA3\xD0\xA4\xD0\xA5\xD0\xA6\xD0\xA7\xD0\xA8\xD0\xA9
"
"
\xD0\xAA\xD0\xAB\xD0\xAC\xD0\xAD\xD0\xAE\xD0\xAF
"
);
// bounds
lines
.
push_back
(
"-
\xD0\x80
-
\xD0\x8E
-
\xD0\x8F
-"
);
lines
.
push_back
(
"-
\xD1\x90
-
\xD1\x91
-
\xD1\xBF
-"
);
// bad utf8
lines
.
push_back
(
"-
\x81
-
\x82
-
\x83
-"
);
lines
.
push_back
(
"--
\xF0
--"
);
lines
.
push_back
(
"-
\xF0
"
);
vector
<
int
>
fonts
;
fonts
.
push_back
(
FONT_HERSHEY_SIMPLEX
);
fonts
.
push_back
(
FONT_HERSHEY_PLAIN
);
fonts
.
push_back
(
FONT_HERSHEY_DUPLEX
);
fonts
.
push_back
(
FONT_HERSHEY_COMPLEX
);
fonts
.
push_back
(
FONT_HERSHEY_TRIPLEX
);
fonts
.
push_back
(
FONT_HERSHEY_COMPLEX_SMALL
);
fonts
.
push_back
(
FONT_HERSHEY_SCRIPT_SIMPLEX
);
fonts
.
push_back
(
FONT_HERSHEY_SCRIPT_COMPLEX
);
vector
<
Mat
>
results
;
Size
bigSize
(
0
,
0
);
for
(
vector
<
int
>::
const_iterator
font
=
fonts
.
begin
();
font
!=
fonts
.
end
();
++
font
)
{
for
(
int
italic
=
0
;
italic
<=
FONT_ITALIC
;
italic
+=
FONT_ITALIC
)
{
for
(
vector
<
string
>::
const_iterator
line
=
lines
.
begin
();
line
!=
lines
.
end
();
++
line
)
{
const
float
fontScale
=
1
;
const
int
thickness
=
1
;
const
Scalar
color
(
20
,
20
,
20
);
int
baseline
=
0
;
Size
textSize
=
getTextSize
(
*
line
,
*
font
|
italic
,
fontScale
,
thickness
,
&
baseline
);
Point
textOrg
(
0
,
textSize
.
height
+
2
);
Mat
img
(
textSize
+
Size
(
0
,
baseline
),
CV_8UC3
,
Scalar
(
255
,
255
,
255
));
putText
(
img
,
*
line
,
textOrg
,
*
font
|
italic
,
fontScale
,
color
,
thickness
,
CV_AA
);
results
.
push_back
(
img
);
bigSize
.
width
=
max
(
bigSize
.
width
,
img
.
size
().
width
);
bigSize
.
height
+=
img
.
size
().
height
+
1
;
}
}
}
int
shift
=
0
;
Mat
result
(
bigSize
,
CV_8UC3
,
Scalar
(
100
,
100
,
100
));
for
(
vector
<
Mat
>::
const_iterator
img
=
results
.
begin
();
img
!=
results
.
end
();
++
img
)
{
Rect
roi
(
Point
(
0
,
shift
),
img
->
size
());
Mat
sub
(
result
,
roi
);
img
->
copyTo
(
sub
);
shift
+=
img
->
size
().
height
+
1
;
}
// imwrite("all_fonts.png", result);
}
};
TEST
(
Highgui_Drawing
,
utf8_support
)
{
CV_DrawingTest_UTF8
test
;
test
.
safe_run
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment