Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -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 | } |