// output layer name is yolov10s/yolov8_nms_postprocess
ObjectDetection<T>::getOutputTensor(names[0], output_tensor);
+ auto scoreMetaInfo = _config->getOutputMetaMap().at(names[0]);
+ auto decodingScore = static_pointer_cast<DecodingScore>(scoreMetaInfo->decodingTypeMap[DecodingType::SCORE]);
+
+ LOGD("threshold = %f", decodingScore->threshold);
+
auto ori_src_width = static_cast<float>(_preprocess.getImageWidth()[0]);
auto ori_src_height = static_cast<float>(_preprocess.getImageHeight()[0]);
auto input_tensor_width = static_cast<float>(_inference->getInputWidth());
// Calculates the width and height ratios between the original source dimensions and the input tensor dimensions.
auto width_ratio = ori_src_width / input_tensor_width;
auto height_ratio = ori_src_height / input_tensor_height;
+
unsigned int class_id = 0;
+ size_t tensor_idx = 0;
- for (size_t tensor_idx = 0; tensor_idx < output_tensor.size(); ++tensor_idx) {
+ while (tensor_idx < output_tensor.size()) {
float num_of_classes;
- num_of_classes = output_tensor[tensor_idx];
+ num_of_classes = output_tensor[tensor_idx++];
if (num_of_classes <= 0.0f) {
class_id++;
continue;
// Calculates the coordinates of a bounding box from the output tensor values.
// - It computes the top, left, bottom, and right coordinates of a bounding box
// based on the given output tensor values and scaling factors for height and width.
- top = height_ratio * input_tensor_height * output_tensor[++tensor_idx];
- left = width_ratio * input_tensor_width * output_tensor[++tensor_idx];
- bottom = height_ratio * input_tensor_height * output_tensor[++tensor_idx];
- right = width_ratio * input_tensor_width * output_tensor[++tensor_idx];
- confidence = output_tensor[++tensor_idx];
- if (confidence < 0.6f)
+ top = height_ratio * input_tensor_height * output_tensor[tensor_idx++];
+ left = width_ratio * input_tensor_width * output_tensor[tensor_idx++];
+ bottom = height_ratio * input_tensor_height * output_tensor[tensor_idx++];
+ right = width_ratio * input_tensor_width * output_tensor[tensor_idx++];
+ confidence = output_tensor[tensor_idx++];
+ if (confidence < decodingScore->threshold)
continue;
valid_objects++;
_result.right.push_back(static_cast<int>(right));
_result.confidences.push_back(confidence);
_result.names.push_back(_labels[class_id]);
+ _result.indices.push_back(class_id);
}
_result.number_of_objects += valid_objects;
- _result.indices.push_back(class_id++);
+ class_id++;
}
return _result;