-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Description
System Information
OpenCV version: 4.10.0 & 5.0.0
File: yolo_detection.cpp (4.x version) / object_detection.cpp (5.x version)
Detailed description
In the OpenCV 4.10.0, within the yolo_detection.cpp file at line 224, the Image2BlobParams object is instantiated as follows:
Scalar scale = parser.get<float>("scale");
It should be changed to use the Scalar::all() function like this:
Scalar scale = Scalar::all(parser.get<float>("scale"));
Similarly, in the OpenCV 5.0.0-pre version, within the object_detection.cpp file at lines 402 and 606, there are comparable implementations where the global variable scale is of type float. In these cases, the Scalar::all() function should also be utilized to apply the scaling factor correctly across all channels.
At line 401, I think the below is correct:
Image2BlobParams imgParams(
Scalar::all(scale),
size,
meanv,
swapRB,
CV_32F,
DNN_LAYOUT_NCHW,
paddingMode,
paddingValue);
Also at line 605:
Image2BlobParams paramNet;
paramNet.scalefactor = Scalar::all(scale);
paramNet.size = Size(inpWidth, inpHeight);
paramNet.mean = meanv;
paramNet.swapRB = swapRB;
paramNet.paddingmode = paddingMode;
Steps to reproduce
Even though using the current code doesn't produce an error message, reviewing the implementation of the Image2BlobParams class shows that it's correct to use the Scalar::all() function when a float argument is passed.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)