Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
ffmpeg
Commits
96c79d4e
Commit
96c79d4e
authored
May 17, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_ocr: also export confidence of result
parent
3f317269
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
filters.texi
doc/filters.texi
+1
-0
vf_ocr.c
libavfilter/vf_ocr.c
+10
-0
No files found.
doc/filters.texi
View file @
96c79d4e
...
@@ -12910,6 +12910,7 @@ Set character blacklist.
...
@@ -12910,6 +12910,7 @@ Set character blacklist.
@end table
@end table
The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
The filter exports confidence of recognized words as the frame metadata @code{lavfi.ocr.confidence}.
@section ocv
@section ocv
...
...
libavfilter/vf_ocr.c
View file @
96c79d4e
...
@@ -100,11 +100,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -100,11 +100,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
OCRContext
*
s
=
ctx
->
priv
;
OCRContext
*
s
=
ctx
->
priv
;
char
*
result
;
char
*
result
;
int
*
confs
;
result
=
TessBaseAPIRect
(
s
->
tess
,
in
->
data
[
0
],
1
,
result
=
TessBaseAPIRect
(
s
->
tess
,
in
->
data
[
0
],
1
,
in
->
linesize
[
0
],
0
,
0
,
in
->
width
,
in
->
height
);
in
->
linesize
[
0
],
0
,
0
,
in
->
width
,
in
->
height
);
confs
=
TessBaseAPIAllWordConfidences
(
s
->
tess
);
av_dict_set
(
metadata
,
"lavfi.ocr.text"
,
result
,
0
);
av_dict_set
(
metadata
,
"lavfi.ocr.text"
,
result
,
0
);
for
(
int
i
=
0
;
confs
[
i
]
!=
-
1
;
i
++
)
{
char
number
[
256
];
snprintf
(
number
,
sizeof
(
number
),
"%d "
,
confs
[
i
]);
av_dict_set
(
metadata
,
"lavfi.ocr.confidence"
,
number
,
AV_DICT_APPEND
);
}
TessDeleteText
(
result
);
TessDeleteText
(
result
);
TessDeleteIntArray
(
confs
);
return
ff_filter_frame
(
outlink
,
in
);
return
ff_filter_frame
(
outlink
,
in
);
}
}
...
...
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