History

avfilter/vf_ocr: also export confidence of result

Paul B Mahol committed 7 years ago

Commit 96c79d41 parent 3f317262 files · +11 −0Browse files

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/vf_ocr.c+10−0
@@ -100,11 +100,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 99 unmodified lines
100100 AVFilterLink *outlink = ctx->outputs[0];
101101 OCRContext *s = ctx->priv;
102102 char *result;
103+ int *confs;
103104
104105 result = TessBaseAPIRect(s->tess, in->data[0], 1,
105106 in->linesize[0], 0, 0, in->width, in->height);
107+ confs = TessBaseAPIAllWordConfidences(s->tess);
106108 av_dict_set(metadata, "lavfi.ocr.text", result, 0);
109+ for (int i = 0; confs[i] != -1; i++) {
110+ char number[256];
111+
112+ snprintf(number, sizeof(number), "%d ", confs[i]);
113+ av_dict_set(metadata, "lavfi.ocr.confidence", number, AV_DICT_APPEND);
114+ }
115+
107116 TessDeleteText(result);
117+ TessDeleteIntArray(confs);
108118
109119 return ff_filter_frame(outlink, in);
110120 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t