Open StephanHasler opened 3 years ago
It's just a sign of whether or not the R/B channels need to be swapped
Yes, as I sad the code is correct, but misleading.
As a user it is sometimes hard to find out whether a deep learning framework uses rgb or bgr internally. Darknet seems to use RGB. But this is hard to find out, if you use a wrong/misleading color conversion constant.
In general, besides being correct, code should reveal the intent of the developer. The contrary is done here.
https://github.com/AlexeyAB/darknet/blob/1be96802a030ae2216c7e19b7523e1e2f0948aaf/src/image_opencv.cpp#L120
Here a conversion RGB2BGR is done. This means from RGB to BGR. But imread delivers the image as BGR not RGB.
The code still does the correct thing as it just swaps the 1st with the 3rd channel. But using RGB2BGR is misleading. It gives the impression that you have RGB and want BGR. But you have BGR and want RGB, I guess.
Correct would be to use BGR2RGB.
Please check also the other transformations in image_opencv.cpp. I guess, whenever you like to convert from cv to internal, it should be BGR2RGB, e.g. loading. And whenever you like to convert from internal to cv, it should be RGB2BGR, e.g. drawing.