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
100 AVFilterLink *outlink = ctx->outputs[0];100 AVFilterLink *outlink = ctx->outputs[0];
101 OCRContext *s = ctx->priv;101 OCRContext *s = ctx->priv;
102 char *result;102 char *result;
103 int *confs;
103 104
104 result = TessBaseAPIRect(s->tess, in->data[0], 1,105 result = TessBaseAPIRect(s->tess, in->data[0], 1,
105 in->linesize[0], 0, 0, in->width, in->height);106 in->linesize[0], 0, 0, in->width, in->height);
107 confs = TessBaseAPIAllWordConfidences(s->tess);
106 av_dict_set(metadata, "lavfi.ocr.text", result, 0);108 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
107 TessDeleteText(result);116 TessDeleteText(result);
117 TessDeleteIntArray(confs);
108 118
109 return ff_filter_frame(outlink, in);119 return ff_filter_frame(outlink, in);
110}120}

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