[FFmpeg-devel] [PATCH V3 1/3] libavfilter/bbox.h: add BoundingBoxHeader and BoundingBox

Guo, Yejun yejun.guo at intel.com
Mon Feb 22 09:30:43 EET 2021


They will be used for filters such as detect and classify.

Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
---
 libavfilter/bbox.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/libavfilter/bbox.h b/libavfilter/bbox.h
index 116158d59e..7c63dfa727 100644
--- a/libavfilter/bbox.h
+++ b/libavfilter/bbox.h
@@ -22,6 +22,51 @@
 #define AVFILTER_BBOX_H
 
 #include <stdint.h>
+#include "libavutil/rational.h"
+
+typedef struct BoundingBoxHeader {
+    /*
+     * Information about how the bounding box is generated.
+     * for example, the DNN model name.
+     */
+    char source[128];
+
+    /* Must be set to the size of BoundingBox (that is,
+     * sizeof(BoundingBox)).
+     */
+    uint32_t bbox_size;
+} BoundingBoxHeader;
+
+typedef struct BoundingBox {
+    /**
+     * Distance in pixels from the top edge of the frame to top
+     * and bottom, and from the left edge of the frame to left and
+     * right, defining the bounding box.
+     */
+    int top;
+    int left;
+    int bottom;
+    int right;
+
+#define BBOX_LABEL_NAME_MAX_LENGTH 32
+
+    /**
+     * Detect result with confidence
+     */
+    char detect_label[BBOX_LABEL_NAME_MAX_LENGTH+1];
+    AVRational detect_confidence;
+
+    /**
+     * At most 4 classifications based on the detected bounding box.
+     * For example, we can get max 4 different attributes with 4 different
+     * DNN models on one bounding box.
+     * classify_count is zero if no classification.
+     */
+#define AV_NUM_BBOX_CLASSIFY 4
+    uint32_t classify_count;
+    char classify_labels[AV_NUM_BBOX_CLASSIFY][BBOX_LABEL_NAME_MAX_LENGTH+1];
+    AVRational classify_confidences[AV_NUM_BBOX_CLASSIFY];
+} BoundingBox;
 
 typedef struct FFBoundingBox {
     int x1, x2, y1, y2;
-- 
2.17.1



More information about the ffmpeg-devel mailing list