From 42be822c1d615f54307e656322f2bf92fb74bda3 Mon Sep 17 00:00:00 2001 From: KangJialiang <60818198+KangJialiang@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:16:21 +0800 Subject: [PATCH] Fix normalization parameters in YOLO example to support multi-channel mean and scale factors This branch and commit address an issue in the YOLO example (samples/dnn/yolo_detector.cpp) where the mean and scale parameters only affected the first channel (B) due to single-value input. The modification updates these parameters to accept multi-channel values, ensuring consistent preprocessing across all image channels. --- samples/dnn/yolo_detector.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/dnn/yolo_detector.cpp b/samples/dnn/yolo_detector.cpp index bd82acff4a..2f1d6dbb49 100644 --- a/samples/dnn/yolo_detector.cpp +++ b/samples/dnn/yolo_detector.cpp @@ -44,8 +44,8 @@ std::string keys = "{ nc | 80 | Number of classes. Default is 80 (coming from COCO dataset). }" "{ thr | .5 | Confidence threshold. }" "{ nms | .4 | Non-maximum suppression threshold. }" - "{ mean | 0.0 | Normalization constant. }" - "{ scale | 1.0 | Preprocess input image by multiplying on a scale factor. }" + "{ mean | 0.0 0.0 0.0 | Normalization constant. }" + "{ scale | 1.0 1.0 1.0 | Preprocess input image by multiplying on a scale factor. }" "{ width | 640 | Preprocess input image by resizing to a specific width. }" "{ height | 640 | Preprocess input image by resizing to a specific height. }" "{ rgb | 1 | Indicate that model works with RGB input images instead BGR ones. }" @@ -221,7 +221,7 @@ int main(int argc, char** argv) bool swapRB = parser.get("rgb"); int inpWidth = parser.get("width"); int inpHeight = parser.get("height"); - Scalar scale = parser.get("scale"); + Scalar scale = parser.get("scale"); Scalar mean = parser.get("mean"); ImagePaddingMode paddingMode = static_cast(parser.get("paddingmode")); //![preprocess_params]