From e7cfc5dc6ce4ba5981b6ce5c8177f114999c88e9 Mon Sep 17 00:00:00 2001 From: ijnek Date: Sat, 16 Nov 2024 16:41:02 +0000 Subject: [PATCH] ensure same format encoding happens for all encoded types --- cv_bridge/src/cv_bridge.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cv_bridge/src/cv_bridge.cpp b/cv_bridge/src/cv_bridge.cpp index dd11c78d2..e763e5da7 100644 --- a/cv_bridge/src/cv_bridge.cpp +++ b/cv_bridge/src/cv_bridge.cpp @@ -121,7 +121,7 @@ int getCvType(const std::string & encoding) /// @cond DOXYGEN_IGNORE enum Encoding { INVALID = -1, GRAY = 0, RGB, BGR, RGBA, BGRA, YUV422, YUV422_YUY2, BAYER_RGGB, BAYER_BGGR, - BAYER_GBRG, BAYER_GRBG}; + BAYER_GBRG, BAYER_GRBG, MAX_ENCODING}; Encoding getEncoding(const std::string & encoding) { @@ -151,7 +151,7 @@ static const int SAME_FORMAT = -1; std::map, std::vector> getConversionCodes() { std::map, std::vector> res; - for (int i = 0; i <= 5; ++i) { + for (int i = 0; i < MAX_ENCODING; ++i) { res[std::pair(Encoding(i), Encoding(i))].push_back(SAME_FORMAT); } @@ -599,7 +599,7 @@ CvImageConstPtr cvtColorForDisplay( } else { // We choose BGR by default here as we assume people will use OpenCV if ((enc::bitDepth(source->encoding) == 8) || - (enc::bitDepth(source->encoding) == 16) || + (enc::bitDepth(source->encoding) == 16) || (enc::bitDepth(source->encoding) == 32)) { encoding = enc::BGR8;