From 1cd70589056bc139693a2a9f29d5af137c2189f9 Mon Sep 17 00:00:00 2001 From: Xing Song Date: Fri, 15 May 2026 04:41:43 +0800 Subject: [PATCH] temp Signed-off-by: Xing Song --- examples/yolov8/cpp/src/postprocess.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/examples/yolov8/cpp/src/postprocess.cpp b/examples/yolov8/cpp/src/postprocess.cpp index 57ac8c8..32f7057 100755 --- a/examples/yolov8/cpp/src/postprocess.cpp +++ b/examples/yolov8/cpp/src/postprocess.cpp @@ -156,7 +156,7 @@ cv::Mat quantize_input(const cv::Mat& float_img, float scale, int8_t zero_point) } static std::vector get_detections(float* output, std::tuple output_shape, - int stride, float conf_thresh) { + int stride, float conf_thresh, int index) { std::vector detections; int grid_h = std::get<0>(output_shape); @@ -208,6 +208,8 @@ static std::vector get_detections(float* output, std::tuple get_detections(float* output, std::tuple postprocess(std::tuple, int> out0, std::tuple, int> out1, std::tuple, int> out2, + std::tuple, int> out3, std::tuple> input_tuple, float conf_thresh, float iou_threshold) { float scale = std::get<1>(input_tuple); int pad_left = std::get<0>(std::get<2>(input_tuple)); int pad_top = std::get<1>(std::get<2>(input_tuple)); + int index = 0; std::vector detections; - auto process_out = [&](auto& out) { + auto process_out = [&](auto& out, auto& index) { float* output = std::get<0>(out); auto shape = std::get<1>(out); int stride = std::get<2>(out); - std::vector dets = get_detections(output, shape, stride, conf_thresh); + std::vector dets = get_detections(output, shape, stride, conf_thresh, index); detections.insert(detections.end(), dets.begin(), dets.end()); + index += }; // Process all three scales @@ -255,6 +261,13 @@ std::vector postprocess(std::tuple, // Map coordinates back to original image std::vector detections_orig; for (const auto& det : detections) { + for (int j = 0; j < 17; i++) { + Keypoint* keypoint = det.keypoint; + keypoint[j].x = (out3[j*3*8400+0*8400+det.keypoint_index] - pad_left) / scale; + keypoint[j].y = (out3[j*3*8400+1*8400+det.keypoint_index] - pad_left) / scale; + keypoint[j].score = out3[j*3*8400+2*8400+det.keypoint_index]; + } + float x1_orig = (det.x1 - pad_left) / scale; float y1_orig = (det.y1 - pad_top) / scale; float x2_orig = (det.x2 - pad_left) / scale; @@ -266,7 +279,7 @@ std::vector postprocess(std::tuple, x2_orig = std::max(0.0f, x2_orig); y2_orig = std::max(0.0f, y2_orig); - detections_orig.push_back({x1_orig, y1_orig, x2_orig, y2_orig, det.score, det.class_id}); + detections_orig.push_back({x1_orig, y1_orig, x2_orig, y2_orig, det.score, det.class_id, det.keypoint_index, det.keypoint}); } // Apply NMS