summaryrefslogtreecommitdiff
path: root/libavfilter/vf_showinfo.c
diff options
context:
space:
mode:
authorGuo, Yejun <yejun.guo@intel.com>2021-01-27 12:54:58 +0800
committerGuo, Yejun <yejun.guo@intel.com>2021-04-17 17:27:02 +0800
commite942b4bbaaddad451752254cbb60a3ea383294d6 (patch)
tree7a9466ad795c3a16568d74d2d1ed3d67da6d9bbb /libavfilter/vf_showinfo.c
parentf1bf465aa03a255e31dfe2a7f25dba85b0d9a36c (diff)
downloadffmpeg-e942b4bbaaddad451752254cbb60a3ea383294d6.tar.gz
lavfi: show side data of detection bounding boxes
Diffstat (limited to 'libavfilter/vf_showinfo.c')
-rw-r--r--libavfilter/vf_showinfo.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 6208892005..ae6f6bb7b1 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -38,6 +38,7 @@
#include "libavutil/timecode.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/video_enc_params.h"
+#include "libavutil/detection_bbox.h"
#include "avfilter.h"
#include "internal.h"
@@ -153,6 +154,31 @@ static void dump_roi(AVFilterContext *ctx, const AVFrameSideData *sd)
}
}
+static void dump_detection_bbox(AVFilterContext *ctx, const AVFrameSideData *sd)
+{
+ int nb_bboxes;
+ const AVDetectionBBoxHeader *header;
+ const AVDetectionBBox *bbox;
+
+ header = (const AVDetectionBBoxHeader *)sd->data;
+ nb_bboxes = header->nb_bboxes;
+ av_log(ctx, AV_LOG_INFO, "detection bounding boxes:\n");
+ av_log(ctx, AV_LOG_INFO, "source: %s\n", header->source);
+
+ for (int i = 0; i < nb_bboxes; i++) {
+ bbox = av_get_detection_bbox(header, i);
+ av_log(ctx, AV_LOG_INFO, "index: %d,\tregion: (%d, %d) -> (%d, %d), label: %s, confidence: %d/%d.\n",
+ i, bbox->x, bbox->y, bbox->x + bbox->w, bbox->y + bbox->h,
+ bbox->detect_label, bbox->detect_confidence.num, bbox->detect_confidence.den);
+ if (bbox->classify_count > 0) {
+ for (int j = 0; j < bbox->classify_count; j++) {
+ av_log(ctx, AV_LOG_INFO, "\t\tclassify: label: %s, confidence: %d/%d.\n",
+ bbox->classify_labels[j], bbox->classify_confidences[j].num, bbox->classify_confidences[j].den);
+ }
+ }
+ }
+}
+
static void dump_mastering_display(AVFilterContext *ctx, const AVFrameSideData *sd)
{
const AVMasteringDisplayMetadata *mastering_display;
@@ -494,6 +520,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
case AV_FRAME_DATA_REGIONS_OF_INTEREST:
dump_roi(ctx, sd);
break;
+ case AV_FRAME_DATA_DETECTION_BBOXES:
+ dump_detection_bbox(ctx, sd);
+ break;
case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
dump_mastering_display(ctx, sd);
break;