diff options
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_ocr.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavfilter/vf_ocr.c b/libavfilter/vf_ocr.c index abfff49438..d5f76059b7 100644 --- a/libavfilter/vf_ocr.c +++ b/libavfilter/vf_ocr.c @@ -100,11 +100,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterLink *outlink = ctx->outputs[0]; OCRContext *s = ctx->priv; char *result; + int *confs; result = TessBaseAPIRect(s->tess, in->data[0], 1, in->linesize[0], 0, 0, in->width, in->height); + confs = TessBaseAPIAllWordConfidences(s->tess); 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); + TessDeleteIntArray(confs); return ff_filter_frame(outlink, in); } |