bb_setOption (void **pdata, int opNum, const char *param)
{
BoundingBox *bdata = static_cast<BoundingBox *> (*pdata);
- return bdata->setOption (opNum, param);
+ BoundingBoxOption option = static_cast<BoundingBoxOption> (opNum);
+ return bdata->setOption (option, param);
}
/**
}
/**
- * @brief Apply NMS to the given results (objects[MOBILENET_SSD_DETECTION_MAX])
+ * @brief Apply NMS to the given results (objects[DETECTION_MAX])
* @param[in/out] results The results to be filtered with nms
*/
static void
}
/**
- * @brief Draw with the given results (objects[MOBILENET_SSD_DETECTION_MAX]) to the output buffer
+ * @brief Draw with the given results (objects[DETECTION_MAX]) to the output buffer
* @param[out] out_info The output buffer (RGBA plain)
* @param[in] bdata The bounding-box internal data.
* @param[in] results The final results to be drawn.
}
int
-BoundingBox::setOption (int opNum, const char *param)
+BoundingBox::setOption (BoundingBoxOption option, const char *param)
{
- if (opNum == 0) {
+ if (option == BoundingBoxOption::MODE) {
return setBoxDecodingMode (param);
- } else if (opNum == 1) {
+ } else if (option == BoundingBoxOption::LABEL_PATH) {
return setLabelPath (param);
- } else if (opNum == 2) {
+ } else if (option == BoundingBoxOption::INTERNAL) {
/* option3 = per-decoding-mode option */
return bdata->setOptionInternal (param);
- } else if (opNum == 3) {
+ } else if (option == BoundingBoxOption::VIDEO_SIZE) {
return setVideoSize (param);
- } else if (opNum == 4) {
+ } else if (option == BoundingBoxOption::INPUT_MODEL_SIZE) {
return setInputModelSize (param);
- } else if (opNum == 5) {
+ } else if (option == BoundingBoxOption::TRACK) {
is_track = (int) g_ascii_strtoll (param, NULL, 10);
return TRUE;
- } else if (opNum == 6) {
+ } else if (option == BoundingBoxOption::LOG) {
do_log = (int) g_ascii_strtoll (param, NULL, 10);
return TRUE;
}
/**
* @todo Accept color / border-width / ... with option-2
*/
- GST_INFO ("Property mode-option-%d is ignored", opNum + 1);
+ GST_INFO ("Property mode-option-%d is ignored", static_cast<int> (option) + 1);
return TRUE;
}
MobilenetSSD::MobilenetSSD ()
{
- params[MOBILENET_SSD_PARAMS_THRESHOLD_IDX] = DETECTION_THRESHOLD;
- params[MOBILENET_SSD_PARAMS_Y_SCALE_IDX] = Y_SCALE;
- params[MOBILENET_SSD_PARAMS_X_SCALE_IDX] = X_SCALE;
- params[MOBILENET_SSD_PARAMS_H_SCALE_IDX] = H_SCALE;
- params[MOBILENET_SSD_PARAMS_W_SCALE_IDX] = W_SCALE;
- params[MOBILENET_SSD_PARAMS_IOU_THRESHOLD_IDX] = THRESHOLD_IOU;
- sigmoid_threshold = logit (DETECTION_THRESHOLD);
+ params[THRESHOLD_IDX] = DETECTION_THRESHOLD_DEFAULT;
+ params[Y_SCALE_IDX] = Y_SCALE_DEFAULT;
+ params[X_SCALE_IDX] = X_SCALE_DEFAULT;
+ params[H_SCALE_IDX] = H_SCALE_DEFAULT;
+ params[W_SCALE_IDX] = W_SCALE_DEFAULT;
+ params[IOU_THRESHOLD_IDX] = THRESHOLD_IOU_DEFAULT;
+ sigmoid_threshold = logit (DETECTION_THRESHOLD_DEFAULT);
max_detection = 0;
total_labels = 0;
column++;
if (word && *word) {
- if (registered > MOBILENET_SSD_DETECTION_MAX) {
+ if (registered > DETECTION_MAX) {
GST_WARNING ("Decoder/Bound-Box/SSD's box prior data file has too many priors. %d >= %d",
- registered, MOBILENET_SSD_DETECTION_MAX);
+ registered, DETECTION_MAX);
break;
}
box_priors[row][registered] = (gfloat) g_ascii_strtod (word, NULL);
options = g_strsplit (param, ":", -1);
noptions = g_strv_length (options);
- if (noptions > (MOBILENET_SSD_PARAMS_MAX + 1))
- noptions = MOBILENET_SSD_PARAMS_MAX + 1;
+ if (noptions > (PARAMS_MAX + 1))
+ noptions = PARAMS_MAX + 1;
if (box_prior_path) {
g_free (box_prior_path);
params[idx - 1] = strtod (options[idx], NULL);
}
- sigmoid_threshold = logit (params[MOBILENET_SSD_PARAMS_THRESHOLD_IDX]);
+ sigmoid_threshold = logit (params[THRESHOLD_IDX]);
return TRUE;
int i;
guint max_detection, max_label;
- if (!_check_tensors (config, MOBILENET_SSD_MAX_TENSORS))
+ if (!_check_tensors (config, MAX_TENSORS))
return FALSE;
/* Check if the first tensor is compatible */
else
g_return_val_if_fail (max_detection == this->max_detection, FALSE);
- if (this->max_detection > MOBILENET_SSD_DETECTION_MAX) {
+ if (this->max_detection > DETECTION_MAX) {
GST_ERROR ("Incoming tensor has too large detection-max : %u", max_detection);
return FALSE;
}
*/
/* Already checked with getOutCaps. Thus, this is an internal bug */
- g_assert (num_tensors >= MOBILENET_SSD_MAX_TENSORS);
+ g_assert (num_tensors >= MAX_TENSORS);
results = g_array_sized_new (FALSE, TRUE, sizeof (detectedObject), 100);
boxes = &input[0];
- if (num_tensors >= MOBILENET_SSD_MAX_TENSORS) /* lgtm[cpp/constant-comparison] */
+ if (num_tensors >= MAX_TENSORS) /* lgtm[cpp/constant-comparison] */
detections = &input[1];
switch (config->info.info[0].type) {
default:
g_assert (0);
}
- nms (results, params[MOBILENET_SSD_PARAMS_IOU_THRESHOLD_IDX]);
+ nms (results, params[IOU_THRESHOLD_IDX]);
return results;
}
MobilenetSSDPP::MobilenetSSDPP ()
{
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_LOCATIONS]
- = MOBILENET_SSD_PP_BBOX_IDX_LOCATIONS_DEFAULT;
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_CLASSES] = MOBILENET_SSD_PP_BBOX_IDX_CLASSES_DEFAULT;
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_SCORES] = MOBILENET_SSD_PP_BBOX_IDX_SCORES_DEFAULT;
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_NUM] = MOBILENET_SSD_PP_BBOX_IDX_NUM_DEFAULT;
- threshold = MOBILENET_SSD_PP_BBOX_THRESHOLD_DEFAULT;
+ tensor_mapping[LOCATIONS_IDX] = LOCATIONS_DEFAULT;
+ tensor_mapping[CLASSES_IDX] = CLASSES_DEFAULT;
+ tensor_mapping[SCORES_IDX] = SCORES_DEFAULT;
+ tensor_mapping[NUM_IDX] = NUM_DEFAULT;
+ threshold = THRESHOLD_DEFAULT;
}
/** @brief Helper to retrieve tensor index by feature */
int
-MobilenetSSDPP::get_mobilenet_ssd_pp_tensor_idx (mobilenet_ssd_pp_bbox_idx_t idx)
+MobilenetSSDPP::get_mobilenet_ssd_pp_tensor_idx (int idx)
{
return tensor_mapping[idx];
}
MobilenetSSDPP::setOptionInternal (const char *param)
{
int threshold_percent;
- int ret = sscanf (param, "%i:%i:%i:%i,%i",
- &tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_LOCATIONS],
- &tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_CLASSES],
- &tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_SCORES],
- &tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_NUM], &threshold_percent);
+ int ret = sscanf (param, "%i:%i:%i:%i,%i", &tensor_mapping[LOCATIONS_IDX],
+ &tensor_mapping[CLASSES_IDX], &tensor_mapping[SCORES_IDX],
+ &tensor_mapping[NUM_IDX], &threshold_percent);
if ((ret == EOF) || (ret < 5)) {
GST_ERROR ("Invalid options, must be \"locations idx:classes idx:scores idx:num idx,threshold\"");
GST_INFO ("MOBILENET SSD POST PROCESS output tensors mapping: "
"locations idx (%d), classes idx (%d), scores idx (%d), num detections idx (%d)",
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_LOCATIONS],
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_CLASSES],
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_SCORES],
- tensor_mapping[MOBILENET_SSD_PP_BBOX_IDX_NUM]);
+ tensor_mapping[LOCATIONS_IDX], tensor_mapping[CLASSES_IDX],
+ tensor_mapping[SCORES_IDX], tensor_mapping[NUM_IDX]);
if ((threshold_percent > 100) || (threshold_percent < 0)) {
GST_ERROR ("Invalid MOBILENET SSD POST PROCESS threshold detection (%i), must be in range [0 100]",
const uint32_t *dim1, *dim2, *dim3, *dim4;
int locations_idx, classes_idx, scores_idx, num_idx, i;
- if (!_check_tensors (config, MOBILENET_SSD_PP_MAX_TENSORS))
+ if (!_check_tensors (config, MAX_TENSORS))
return FALSE;
- locations_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_LOCATIONS);
- classes_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_CLASSES);
- scores_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_SCORES);
- num_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_NUM);
+ locations_idx = get_mobilenet_ssd_pp_tensor_idx (LOCATIONS_IDX);
+ classes_idx = get_mobilenet_ssd_pp_tensor_idx (CLASSES_IDX);
+ scores_idx = get_mobilenet_ssd_pp_tensor_idx (SCORES_IDX);
+ num_idx = get_mobilenet_ssd_pp_tensor_idx (NUM_IDX);
/* Check if the number of detections tensor is compatible */
dim1 = config->info.info[num_idx].dimension;
else
g_return_val_if_fail (max_detection == this->max_detection, FALSE);
- if (this->max_detection > MOBILENET_SSD_DETECTION_MAX) {
+ if (this->max_detection > DETECTION_MAX) {
GST_ERROR ("Incoming tensor has too large detection-max : %u", max_detection);
return FALSE;
}
const guint num_tensors = config->info.num_tensors;
/* Already checked with getOutCaps. Thus, this is an internal bug */
- g_assert (num_tensors >= MOBILENET_SSD_PP_MAX_TENSORS);
+ g_assert (num_tensors >= MAX_TENSORS);
- locations_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_LOCATIONS);
- classes_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_CLASSES);
- scores_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_SCORES);
- num_idx = get_mobilenet_ssd_pp_tensor_idx (MOBILENET_SSD_PP_BBOX_IDX_NUM);
+ locations_idx = get_mobilenet_ssd_pp_tensor_idx (LOCATIONS_IDX);
+ classes_idx = get_mobilenet_ssd_pp_tensor_idx (CLASSES_IDX);
+ scores_idx = get_mobilenet_ssd_pp_tensor_idx (SCORES_IDX);
+ num_idx = get_mobilenet_ssd_pp_tensor_idx (NUM_IDX);
mem_num = &input[num_idx];
mem_classes = &input[classes_idx];
int i;
UNUSED (total_labels);
- if (!_check_tensors (config, OV_PERSON_DETECTION_MAX_TENSORS))
+ if (!_check_tensors (config, DEFAULT_MAX_TENSORS))
return FALSE;
/**
* number (i.e., 200) of detected bounding boxes.
*/
dim = config->info.info[0].dimension;
- g_return_val_if_fail (dim[0] == OV_PERSON_DETECTION_SIZE_DETECTION_DESC, FALSE);
- g_return_val_if_fail (dim[1] == OV_PERSON_DETECTION_MAX, FALSE);
+ g_return_val_if_fail (dim[0] == DEFAULT_SIZE_DETECTION_DESC, FALSE);
+ g_return_val_if_fail (dim[1] == DETECTION_MAX, FALSE);
for (i = 2; i < NNS_TENSOR_RANK_LIMIT; ++i)
g_return_val_if_fail (dim[i] == 0 || dim[i] == 1, FALSE);
const guint num_tensors = config->info.num_tensors;
/* Already checked with getOutCaps. Thus, this is an internal bug */
- g_assert (num_tensors >= OV_PERSON_DETECTION_MAX_TENSORS);
+ g_assert (num_tensors >= DEFAULT_MAX_TENSORS);
- results = g_array_sized_new (FALSE, TRUE, sizeof (detectedObject), OV_PERSON_DETECTION_MAX);
+ results = g_array_sized_new (FALSE, TRUE, sizeof (detectedObject), DETECTION_MAX);
switch (config->info.info[0].type) {
_get_persons_ov (uint8_t, input[0].data, _NNS_UINT8, results);
_get_persons_ov (int8_t, input[0].data, _NNS_INT8, results);
+ (i_width / 8) * (i_height / 8))
* 3;
- g_return_val_if_fail (dim[0] == (total_labels + YOLOV5_DETECTION_NUM_INFO), FALSE);
+ g_return_val_if_fail (dim[0] == (total_labels + DEFAULT_DETECTION_NUM_INFO), FALSE);
g_return_val_if_fail (dim[1] == max_detection, FALSE);
for (i = 2; i < NNS_TENSOR_RANK_LIMIT; ++i)
g_return_val_if_fail (dim[i] == 0 || dim[i] == 1, FALSE);
numTotalBox = max_detection;
numTotalClass = total_labels;
- cStartIdx = YOLOV5_DETECTION_NUM_INFO;
+ cStartIdx = DEFAULT_DETECTION_NUM_INFO;
cIdxMax = numTotalClass + cStartIdx;
/* boxinput[numTotalBox][cIdxMax] */
object.height = (int) (MIN ((float) i_height, h));
object.prob = maxClassConfVal * boxinput[bIdx * cIdxMax + 4];
- object.class_id = maxClassIdx - YOLOV5_DETECTION_NUM_INFO;
+ object.class_id = maxClassIdx - DEFAULT_DETECTION_NUM_INFO;
object.tracking_id = 0;
object.valid = TRUE;
g_array_append_val (results, object);
max_detection = (i_width / 32) * (i_height / 32) + (i_width / 16) * (i_height / 16)
+ (i_width / 8) * (i_height / 8);
- if (dim[0] != (total_labels + YOLOV8_DETECTION_NUM_INFO) || dim[1] != max_detection) {
+ if (dim[0] != (total_labels + DEFAULT_DETECTION_NUM_INFO) || dim[1] != max_detection) {
nns_loge ("yolov8 boundingbox decoder requires the input shape to be %d:%d:1. But given shape is %d:%d:1. `tensor_transform mode=transpose` would be helpful.",
- total_labels + YOLOV8_DETECTION_NUM_INFO, max_detection, dim[0], dim[1]);
+ total_labels + DEFAULT_DETECTION_NUM_INFO, max_detection, dim[0], dim[1]);
return FALSE;
}
numTotalBox = max_detection;
numTotalClass = total_labels;
- cStartIdx = YOLOV8_DETECTION_NUM_INFO;
+ cStartIdx = DEFAULT_DETECTION_NUM_INFO;
cIdxMax = numTotalClass + cStartIdx;
/* boxinput[numTotalBox][cIdxMax] */
object.height = (int) (MIN ((float) i_height, h));
object.prob = maxClassConfVal;
- object.class_id = maxClassIdx - YOLOV8_DETECTION_NUM_INFO;
+ object.class_id = maxClassIdx - DEFAULT_DETECTION_NUM_INFO;
object.tracking_id = 0;
object.valid = TRUE;
g_array_append_val (results, object);
MpPalmDetection::MpPalmDetection ()
{
- num_layers = MP_PALM_DETECTION_NUM_LAYERS_DEFAULT;
- min_scale = MP_PALM_DETECTION_MIN_SCALE_DEFAULT;
- max_scale = MP_PALM_DETECTION_MAX_SCALE_DEFAULT;
- offset_x = MP_PALM_DETECTION_OFFSET_X_DEFAULT;
- offset_y = MP_PALM_DETECTION_OFFSET_Y_DEFAULT;
- strides[0] = MP_PALM_DETECTION_STRIDE_0_DEFAULT;
- strides[1] = MP_PALM_DETECTION_STRIDE_1_DEFAULT;
- strides[2] = MP_PALM_DETECTION_STRIDE_2_DEFAULT;
- strides[3] = MP_PALM_DETECTION_STRIDE_3_DEFAULT;
- min_score_threshold = MP_PALM_DETECTION_MIN_SCORE_THRESHOLD_DEFAULT;
+ num_layers = NUM_LAYERS_DEFAULT;
+ min_scale = MIN_SCALE_DEFAULT;
+ max_scale = MAX_SCALE_DEFAULT;
+ offset_x = OFFSET_X_DEFAULT;
+ offset_y = OFFSET_Y_DEFAULT;
+ strides[0] = STRIDE_0_DEFAULT;
+ strides[1] = STRIDE_1_DEFAULT;
+ strides[2] = STRIDE_2_DEFAULT;
+ strides[3] = STRIDE_3_DEFAULT;
+ min_score_threshold = MIN_SCORE_THRESHOLD_DEFAULT;
anchors = g_array_new (FALSE, TRUE, sizeof (anchor));
}
options = g_strsplit (param, ":", -1);
noptions = g_strv_length (options);
- if (noptions > MP_PALM_DETECTION_PARAMS_MAX) {
+ if (noptions > PARAMS_MAX) {
GST_ERROR ("Invalid MP PALM DETECTION PARAM length: %d", noptions);
ret = FALSE;
goto exit_mp_palm_detection;
{
const uint32_t *dim1, *dim2;
int i;
- if (!_check_tensors (config, MP_PALM_DETECTION_MAX_TENSORS))
+ if (!_check_tensors (config, MAX_TENSORS))
return FALSE;
/* Check if the first tensor is compatible */
dim1 = config->info.info[0].dimension;
- g_return_val_if_fail (dim1[0] == MP_PALM_DETECTION_INFO_SIZE, FALSE);
+ g_return_val_if_fail (dim1[0] == INFO_SIZE, FALSE);
max_detection = dim1[1];
g_return_val_if_fail (max_detection > 0, FALSE);
g_return_val_if_fail (dim1[2] == 1, FALSE);
else
g_return_val_if_fail (max_detection == this->max_detection, FALSE);
- if (this->max_detection > MP_PALM_DETECTION_DETECTION_MAX) {
+ if (this->max_detection > MAX_DETECTION) {
GST_ERROR ("Incoming tensor has too large detection-max : %u", max_detection);
return FALSE;
}
const guint num_tensors = config->info.num_tensors;
/* Already checked with getOutCaps. Thus, this is an internal bug */
- g_assert (num_tensors >= MP_PALM_DETECTION_MAX_TENSORS);
+ g_assert (num_tensors >= MAX_TENSORS);
/* results will be allocated by _get_objects_mp_palm_detection_ */
boxes = &input[0];
#include <math.h> /* expf */
#include "tensordecutil.h"
-#define BOX_SIZE (4)
-#define MOBILENET_SSD_DETECTION_MAX (2034) /* add ssd_mobilenet v3 support */
-#define MOBILENET_SSD_MAX_TENSORS (2U)
-#define MOBILENET_SSD_PP_DETECTION_MAX (100)
-#define MOBILENET_SSD_PP_MAX_TENSORS (4U)
-#define OV_PERSON_DETECTION_MAX (200U)
-#define OV_PERSON_DETECTION_MAX_TENSORS (1U)
-#define OV_PERSON_DETECTION_SIZE_DETECTION_DESC (7)
-#define OV_PERSON_DETECTION_CONF_THRESHOLD (0.8)
-#define YOLO_DETECTION_CONF_THRESHOLD (0.25)
-#define YOLO_DETECTION_IOU_THRESHOLD (0.45)
-#define YOLOV5_DETECTION_NUM_INFO (5)
-#define YOLOV8_DETECTION_NUM_INFO (4)
#define PIXEL_VALUE (0xFF0000FF) /* RED 100% in RGBA */
-#define MP_PALM_DETECTION_INFO_SIZE (18)
-#define MP_PALM_DETECTION_MAX_TENSORS (2U)
-#define MP_PALM_DETECTION_DETECTION_MAX (2016)
/**
* @brief C++-Template-like box location calculation for box-priors for Mobilenet SSD Model
size_t boxbpi = config->info.info[0].dimension[0]; \
_type *detinput_ = (_type *) detinput; \
size_t detbpi = config->info.info[1].dimension[0]; \
- int num = (MOBILENET_SSD_DETECTION_MAX > max_detection) ? max_detection : MOBILENET_SSD_DETECTION_MAX; \
+ int num = (DETECTION_MAX > max_detection) ? max_detection : DETECTION_MAX; \
detectedObject object = { \
.valid = FALSE, .class_id = 0, .x = 0, .y = 0, .width = 0, .height = 0, .prob = .0, .tracking_id = 0 \
}; \
* @brief C++-Template-like box location calculation for box-priors
* @bug This is not macro-argument safe. Use paranthesis!
* @param[in] bb The configuration, "bounding_boxes"
- * @param[in] index The index (3rd dimension of BOX_SIZE:1:MOBILENET_SSD_DETECTION_MAX:1)
- * @param[in] total_labels The count of total labels. We can get this from input tensor info. (1st dimension of LABEL_SIZE:MOBILENET_SSD_DETECTION_MAX:1:1)
+ * @param[in] index The index (3rd dimension of BOX_SIZE:1:DETECTION_MAX:1)
+ * @param[in] total_labels The count of total labels. We can get this from input tensor info. (1st dimension of LABEL_SIZE:DETECTION_MAX:1:1)
* @param[in] boxprior The box prior data from the box file of SSD.
* @param[in] boxinputptr Cursor pointer of input + byte-per-index * index (box)
* @param[in] detinputptr Cursor pointer of input + byte-per-index * index (detection)
do { \
unsigned int c; \
gfloat highscore = -FLT_MAX; \
- float y_scale = params[MOBILENET_SSD_PARAMS_Y_SCALE_IDX]; \
- float x_scale = params[MOBILENET_SSD_PARAMS_X_SCALE_IDX]; \
- float h_scale = params[MOBILENET_SSD_PARAMS_H_SCALE_IDX]; \
- float w_scale = params[MOBILENET_SSD_PARAMS_W_SCALE_IDX]; \
+ float y_scale = params[Y_SCALE_IDX]; \
+ float x_scale = params[X_SCALE_IDX]; \
+ float h_scale = params[H_SCALE_IDX]; \
+ float w_scale = params[W_SCALE_IDX]; \
result->valid = FALSE; \
for (c = 1; c < total_labels; c++) { \
if (detinputptr[c] >= sigmoid_threshold) { \
} \
} while (0);
+enum class BoundingBoxOption {
+ MODE = 0,
+ LABEL_PATH = 1,
+ INTERNAL = 2,
+ VIDEO_SIZE = 3,
+ INPUT_MODEL_SIZE = 4,
+ TRACK = 5,
+ LOG = 6,
+ UNKNOWN,
+};
+
/**
* @brief There can be different schemes for bounding boxes.
*/
_get_objects_mobilenet_ssd_pp (type, typename, (mem_num->data), (mem_classes->data), \
(mem_scores->data), (mem_boxes->data), config, results, i_width, i_height)
+
+#define OV_PERSON_DETECTION_CONF_THRESHOLD (0.8)
/**
* @brief C++-Template-like box location calculation for OpenVino Person Detection Model
* @param[in] type The tensor type of inputptr
type *typed_inputptr = (type *) inputptr; \
guint d; \
\
- for (d = 1; d <= OV_PERSON_DETECTION_MAX; ++d) { \
+ for (d = 1; d <= DETECTION_MAX; ++d) { \
struct { \
type image_id; \
type label; \
void logBoxes (GArray *results);
void updateCentroids (GArray *boxes);
- int setOption (int opNum, const char *param);
+ int setOption (BoundingBoxOption opNum, const char *param);
GstCaps *getOutCaps (const GstTensorsConfig *config);
GstFlowReturn decode (const GstTensorsConfig *config,
const GstTensorMemory *input, GstBuffer *outbuf);
return log (x / (1.0 - x));
}
-#define MOBILENET_SSD_PARAMS_THRESHOLD_IDX 0
-#define MOBILENET_SSD_PARAMS_Y_SCALE_IDX 1
-#define MOBILENET_SSD_PARAMS_X_SCALE_IDX 2
-#define MOBILENET_SSD_PARAMS_H_SCALE_IDX 3
-#define MOBILENET_SSD_PARAMS_W_SCALE_IDX 4
-#define MOBILENET_SSD_PARAMS_IOU_THRESHOLD_IDX 5
-#define MOBILENET_SSD_PARAMS_MAX 6
-
-#define DETECTION_THRESHOLD (.5f)
-#define THRESHOLD_IOU (.5f)
-#define Y_SCALE (10.0f)
-#define X_SCALE (10.0f)
-#define H_SCALE (5.0f)
-#define W_SCALE (5.0f)
-
class MobilenetSSD : public BoxProperties
{
public:
int checkCompatible (const GstTensorsConfig *config);
GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input);
+ static const int BOX_SIZE = 4;
+ static const int DETECTION_MAX = 2034; /* add ssd_mobilenet v3 support */
+ static const guint MAX_TENSORS = 2U;
+
+ static const int THRESHOLD_IDX = 0;
+ static const int Y_SCALE_IDX = 1;
+ static const int X_SCALE_IDX = 2;
+ static const int H_SCALE_IDX = 3;
+ static const int W_SCALE_IDX = 4;
+ static const int IOU_THRESHOLD_IDX = 5;
+ static const int PARAMS_MAX = 6;
+
+ static constexpr gfloat DETECTION_THRESHOLD_DEFAULT = 0.5f;
+ static constexpr gfloat THRESHOLD_IOU_DEFAULT = 0.5f;
+ static constexpr gfloat Y_SCALE_DEFAULT = 10.0f;
+ static constexpr gfloat X_SCALE_DEFAULT = 10.0f;
+ static constexpr gfloat H_SCALE_DEFAULT = 5.0f;
+ static constexpr gfloat W_SCALE_DEFAULT = 5.0f;
+
private:
char *box_prior_path; /**< Box Prior file path */
- gfloat box_priors[BOX_SIZE][MOBILENET_SSD_DETECTION_MAX + 1]; /** loaded box prior */
- gfloat params[MOBILENET_SSD_PARAMS_MAX]; /** Post Processing parameters */
+ gfloat box_priors[BOX_SIZE][DETECTION_MAX + 1]; /** loaded box prior */
+ gfloat params[PARAMS_MAX]; /** Post Processing parameters */
gfloat sigmoid_threshold; /** Inverse value of valid detection threshold in sigmoid domain */
};
-#define MOBILENET_SSD_PP_BBOX_IDX_LOCATIONS_DEFAULT 3
-#define MOBILENET_SSD_PP_BBOX_IDX_CLASSES_DEFAULT 1
-#define MOBILENET_SSD_PP_BBOX_IDX_SCORES_DEFAULT 2
-#define MOBILENET_SSD_PP_BBOX_IDX_NUM_DEFAULT 0
-#define MOBILENET_SSD_PP_BBOX_THRESHOLD_DEFAULT G_MINFLOAT
class MobilenetSSDPP : public BoxProperties
{
public:
MobilenetSSDPP ();
- int get_mobilenet_ssd_pp_tensor_idx (mobilenet_ssd_pp_bbox_idx_t idx);
+ int get_mobilenet_ssd_pp_tensor_idx (int idx);
int setOptionInternal (const char *param);
int checkCompatible (const GstTensorsConfig *config);
GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input);
+ static const int BOX_SIZE = 4;
+ static const guint DETECTION_MAX = 100;
+ static const guint MAX_TENSORS = 4U;
+ static const int LOCATIONS_IDX = 0;
+ static const int CLASSES_IDX = 1;
+ static const int SCORES_IDX = 2;
+ static const int NUM_IDX = 3;
+
+ static const gint LOCATIONS_DEFAULT = 3;
+ static const gint CLASSES_DEFAULT = 1;
+ static const gint SCORES_DEFAULT = 2;
+ static const gint NUM_DEFAULT = 0;
+ static constexpr gfloat THRESHOLD_DEFAULT = G_MINFLOAT;
+
private:
- gint tensor_mapping[MOBILENET_SSD_PP_MAX_TENSORS]; /* Output tensor index mapping */
+ gint tensor_mapping[MAX_TENSORS]; /* Output tensor index mapping */
gfloat threshold; /* Detection threshold */
};
}
int checkCompatible (const GstTensorsConfig *config);
GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input);
+
+ static const guint DETECTION_MAX = 200U;
+ static const guint DEFAULT_MAX_TENSORS = 1;
+ static const guint DEFAULT_SIZE_DETECTION_DESC = 7;
};
+#define YOLO_DETECTION_CONF_THRESHOLD (0.25)
+#define YOLO_DETECTION_IOU_THRESHOLD (0.45)
+
class YoloV5 : public BoxProperties
{
public:
int checkCompatible (const GstTensorsConfig *config);
GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input);
+ static const int DEFAULT_DETECTION_NUM_INFO = 5;
+
private:
/* From option3, whether the output values are scaled or not */
int scaled_output;
int checkCompatible (const GstTensorsConfig *config);
GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input);
+ static const int DEFAULT_DETECTION_NUM_INFO = 4;
+
private:
/* From option3, whether the output values are scaled or not */
int scaled_output;
gfloat iou_threshold;
};
-/* From option3, anchor data */
-#define MP_PALM_DETECTION_PARAMS_STRIDE_SIZE 8
-#define MP_PALM_DETECTION_PARAMS_MAX 13
-
-#define MP_PALM_DETECTION_NUM_LAYERS_DEFAULT (4)
-#define MP_PALM_DETECTION_MIN_SCALE_DEFAULT (1.0)
-#define MP_PALM_DETECTION_MAX_SCALE_DEFAULT (1.0)
-#define MP_PALM_DETECTION_OFFSET_X_DEFAULT (0.5)
-#define MP_PALM_DETECTION_OFFSET_Y_DEFAULT (0.5)
-#define MP_PALM_DETECTION_STRIDE_0_DEFAULT (8)
-#define MP_PALM_DETECTION_STRIDE_1_DEFAULT (16)
-#define MP_PALM_DETECTION_STRIDE_2_DEFAULT (16)
-#define MP_PALM_DETECTION_STRIDE_3_DEFAULT (16)
-#define MP_PALM_DETECTION_MIN_SCORE_THRESHOLD_DEFAULT (0.5)
-
class MpPalmDetection : public BoxProperties
{
public:
GArray *decode (const GstTensorsConfig *config, const GstTensorMemory *input);
+ static const guint INFO_SIZE = 18;
+ static const guint MAX_TENSORS = 2U;
+ static const guint MAX_DETECTION = 2016;
+
+ static const gint NUM_LAYERS_DEFAULT = 4;
+ static constexpr gfloat MIN_SCALE_DEFAULT = 1.0;
+ static constexpr gfloat MAX_SCALE_DEFAULT = 1.0;
+ static constexpr gfloat OFFSET_X_DEFAULT = 0.5;
+ static constexpr gfloat OFFSET_Y_DEFAULT = 0.5;
+ static const gint STRIDE_0_DEFAULT = 8;
+ static const gint STRIDE_1_DEFAULT = 16;
+ static const gint STRIDE_2_DEFAULT = 16;
+ static const gint STRIDE_3_DEFAULT = 16;
+ static constexpr gfloat MIN_SCORE_THRESHOLD_DEFAULT = 0.5;
+
+ static const int PARAMS_STRIDE_SIZE = 8;
+ static const int PARAMS_MAX = 13;
+
private:
gint num_layers;
/** Number of stride layers */
gfloat max_scale; /** Maximum scale */
gfloat offset_x; /** anchor X offset */
gfloat offset_y; /** anchor Y offset */
- gint strides[MP_PALM_DETECTION_PARAMS_STRIDE_SIZE]; /** Stride data for each layers */
+ gint strides[PARAMS_MAX]; /** Stride data for each layers */
gfloat min_score_threshold; /** minimum threshold of score */
GArray *anchors;