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
59915a3f
Commit
59915a3f
authored
Jan 16, 2018
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10575 from ioxp:getFontScale
parents
be1207e5
6032d86e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+14
-0
drawing.cpp
modules/imgproc/src/drawing.cpp
+11
-0
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
59915a3f
...
...
@@ -4730,6 +4730,20 @@ CV_EXPORTS_W Size getTextSize(const String& text, int fontFace,
double
fontScale
,
int
thickness
,
CV_OUT
int
*
baseLine
);
/** @brief Calculates the font-specific size to use to achieve a given height in pixels.
@param fontFace Font to use, see cv::HersheyFonts.
@param pixelHeight Pixel height to compute the fontScale for
@param thickness Thickness of lines used to render the text.See putText for details.
@return The fontSize to use for cv::putText
@see cv::putText
*/
CV_EXPORTS_W
double
getFontScaleFromHeight
(
const
int
fontFace
,
const
int
pixelHeight
,
const
int
thickness
=
1
);
/** @brief Line iterator
The class is used to iterate over all the pixels on the raster line
...
...
modules/imgproc/src/drawing.cpp
View file @
59915a3f
...
...
@@ -2364,6 +2364,17 @@ Size getTextSize( const String& text, int fontFace, double fontScale, int thickn
return
size
;
}
double
getFontScaleFromHeight
(
const
int
fontFace
,
const
int
pixelHeight
,
const
int
thickness
)
{
// By https://stackoverflow.com/a/27898487/1531708
const
int
*
ascii
=
getFontData
(
fontFace
);
int
base_line
=
(
ascii
[
0
]
&
15
);
int
cap_line
=
(
ascii
[
0
]
>>
4
)
&
15
;
return
static_cast
<
double
>
(
pixelHeight
-
static_cast
<
double
>
((
thickness
+
1
))
/
2.0
)
/
static_cast
<
double
>
(
cap_line
+
base_line
);
}
}
...
...
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