Skip to content

Commit

Permalink
simplify std::make_pair to use aggregate initialization
Browse files Browse the repository at this point in the history
Signed-off-by: ijnek <[email protected]>
  • Loading branch information
ijnek committed Oct 12, 2023
1 parent cff3873 commit 2a2b23a
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions cv_bridge/src/cv_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,62 +156,62 @@ std::map<std::pair<Encoding, Encoding>, std::vector<int>> getConversionCodes()
{
std::map<std::pair<Encoding, Encoding>, std::vector<int>> res;
for (int i = 0; i <= 5; ++i) {
res[std::pair<Encoding, Encoding>(Encoding(i), Encoding(i))].push_back(SAME_FORMAT);
res[{Encoding(i), Encoding(i)}].push_back(SAME_FORMAT);
}

res[std::make_pair(GRAY, RGB)].push_back(cv::COLOR_GRAY2RGB);
res[std::make_pair(GRAY, BGR)].push_back(cv::COLOR_GRAY2BGR);
res[std::make_pair(GRAY, RGBA)].push_back(cv::COLOR_GRAY2RGBA);
res[std::make_pair(GRAY, BGRA)].push_back(cv::COLOR_GRAY2BGRA);

res[std::make_pair(RGB, GRAY)].push_back(cv::COLOR_RGB2GRAY);
res[std::make_pair(RGB, BGR)].push_back(cv::COLOR_RGB2BGR);
res[std::make_pair(RGB, RGBA)].push_back(cv::COLOR_RGB2RGBA);
res[std::make_pair(RGB, BGRA)].push_back(cv::COLOR_RGB2BGRA);

res[std::make_pair(BGR, GRAY)].push_back(cv::COLOR_BGR2GRAY);
res[std::make_pair(BGR, RGB)].push_back(cv::COLOR_BGR2RGB);
res[std::make_pair(BGR, RGBA)].push_back(cv::COLOR_BGR2RGBA);
res[std::make_pair(BGR, BGRA)].push_back(cv::COLOR_BGR2BGRA);

res[std::make_pair(RGBA, GRAY)].push_back(cv::COLOR_RGBA2GRAY);
res[std::make_pair(RGBA, RGB)].push_back(cv::COLOR_RGBA2RGB);
res[std::make_pair(RGBA, BGR)].push_back(cv::COLOR_RGBA2BGR);
res[std::make_pair(RGBA, BGRA)].push_back(cv::COLOR_RGBA2BGRA);

res[std::make_pair(BGRA, GRAY)].push_back(cv::COLOR_BGRA2GRAY);
res[std::make_pair(BGRA, RGB)].push_back(cv::COLOR_BGRA2RGB);
res[std::make_pair(BGRA, BGR)].push_back(cv::COLOR_BGRA2BGR);
res[std::make_pair(BGRA, RGBA)].push_back(cv::COLOR_BGRA2RGBA);

res[std::make_pair(UYVY, GRAY)].push_back(cv::COLOR_YUV2GRAY_UYVY);
res[std::make_pair(UYVY, RGB)].push_back(cv::COLOR_YUV2RGB_UYVY);
res[std::make_pair(UYVY, BGR)].push_back(cv::COLOR_YUV2BGR_UYVY);
res[std::make_pair(UYVY, RGBA)].push_back(cv::COLOR_YUV2RGBA_UYVY);
res[std::make_pair(UYVY, BGRA)].push_back(cv::COLOR_YUV2BGRA_UYVY);

res[std::make_pair(YUYV, GRAY)].push_back(cv::COLOR_YUV2GRAY_YUY2);
res[std::make_pair(YUYV, RGB)].push_back(cv::COLOR_YUV2RGB_YUY2);
res[std::make_pair(YUYV, BGR)].push_back(cv::COLOR_YUV2BGR_YUY2);
res[std::make_pair(YUYV, RGBA)].push_back(cv::COLOR_YUV2RGBA_YUY2);
res[std::make_pair(YUYV, BGRA)].push_back(cv::COLOR_YUV2BGRA_YUY2);
res[{GRAY, RGB}].push_back(cv::COLOR_GRAY2RGB);
res[{GRAY, BGR}].push_back(cv::COLOR_GRAY2BGR);
res[{GRAY, RGBA}].push_back(cv::COLOR_GRAY2RGBA);
res[{GRAY, BGRA}].push_back(cv::COLOR_GRAY2BGRA);

res[{RGB, GRAY}].push_back(cv::COLOR_RGB2GRAY);
res[{RGB, BGR}].push_back(cv::COLOR_RGB2BGR);
res[{RGB, RGBA}].push_back(cv::COLOR_RGB2RGBA);
res[{RGB, BGRA}].push_back(cv::COLOR_RGB2BGRA);

res[{BGR, GRAY}].push_back(cv::COLOR_BGR2GRAY);
res[{BGR, RGB}].push_back(cv::COLOR_BGR2RGB);
res[{BGR, RGBA}].push_back(cv::COLOR_BGR2RGBA);
res[{BGR, BGRA}].push_back(cv::COLOR_BGR2BGRA);

res[{RGBA, GRAY}].push_back(cv::COLOR_RGBA2GRAY);
res[{RGBA, RGB}].push_back(cv::COLOR_RGBA2RGB);
res[{RGBA, BGR}].push_back(cv::COLOR_RGBA2BGR);
res[{RGBA, BGRA}].push_back(cv::COLOR_RGBA2BGRA);

res[{BGRA, GRAY}].push_back(cv::COLOR_BGRA2GRAY);
res[{BGRA, RGB}].push_back(cv::COLOR_BGRA2RGB);
res[{BGRA, BGR}].push_back(cv::COLOR_BGRA2BGR);
res[{BGRA, RGBA}].push_back(cv::COLOR_BGRA2RGBA);

res[{UYVY, GRAY}].push_back(cv::COLOR_YUV2GRAY_UYVY);
res[{UYVY, RGB}].push_back(cv::COLOR_YUV2RGB_UYVY);
res[{UYVY, BGR}].push_back(cv::COLOR_YUV2BGR_UYVY);
res[{UYVY, RGBA}].push_back(cv::COLOR_YUV2RGBA_UYVY);
res[{UYVY, BGRA}].push_back(cv::COLOR_YUV2BGRA_UYVY);

res[{YUYV, GRAY}].push_back(cv::COLOR_YUV2GRAY_YUY2);
res[{YUYV, RGB}].push_back(cv::COLOR_YUV2RGB_YUY2);
res[{YUYV, BGR}].push_back(cv::COLOR_YUV2BGR_YUY2);
res[{YUYV, RGBA}].push_back(cv::COLOR_YUV2RGBA_YUY2);
res[{YUYV, BGRA}].push_back(cv::COLOR_YUV2BGRA_YUY2);

// Deal with Bayer
res[std::make_pair(BAYER_RGGB, GRAY)].push_back(cv::COLOR_BayerBG2GRAY);
res[std::make_pair(BAYER_RGGB, RGB)].push_back(cv::COLOR_BayerBG2RGB);
res[std::make_pair(BAYER_RGGB, BGR)].push_back(cv::COLOR_BayerBG2BGR);
res[{BAYER_RGGB, GRAY}].push_back(cv::COLOR_BayerBG2GRAY);
res[{BAYER_RGGB, RGB}].push_back(cv::COLOR_BayerBG2RGB);
res[{BAYER_RGGB, BGR}].push_back(cv::COLOR_BayerBG2BGR);

res[std::make_pair(BAYER_BGGR, GRAY)].push_back(cv::COLOR_BayerRG2GRAY);
res[std::make_pair(BAYER_BGGR, RGB)].push_back(cv::COLOR_BayerRG2RGB);
res[std::make_pair(BAYER_BGGR, BGR)].push_back(cv::COLOR_BayerRG2BGR);
res[{BAYER_BGGR, GRAY}].push_back(cv::COLOR_BayerRG2GRAY);
res[{BAYER_BGGR, RGB}].push_back(cv::COLOR_BayerRG2RGB);
res[{BAYER_BGGR, BGR}].push_back(cv::COLOR_BayerRG2BGR);

res[std::make_pair(BAYER_GBRG, GRAY)].push_back(cv::COLOR_BayerGR2GRAY);
res[std::make_pair(BAYER_GBRG, RGB)].push_back(cv::COLOR_BayerGR2RGB);
res[std::make_pair(BAYER_GBRG, BGR)].push_back(cv::COLOR_BayerGR2BGR);
res[{BAYER_GBRG, GRAY}].push_back(cv::COLOR_BayerGR2GRAY);
res[{BAYER_GBRG, RGB}].push_back(cv::COLOR_BayerGR2RGB);
res[{BAYER_GBRG, BGR}].push_back(cv::COLOR_BayerGR2BGR);

res[std::make_pair(BAYER_GRBG, GRAY)].push_back(cv::COLOR_BayerGB2GRAY);
res[std::make_pair(BAYER_GRBG, RGB)].push_back(cv::COLOR_BayerGB2RGB);
res[std::make_pair(BAYER_GRBG, BGR)].push_back(cv::COLOR_BayerGB2BGR);
res[{BAYER_GRBG, GRAY}].push_back(cv::COLOR_BayerGB2GRAY);
res[{BAYER_GRBG, RGB}].push_back(cv::COLOR_BayerGB2RGB);
res[{BAYER_GRBG, BGR}].push_back(cv::COLOR_BayerGB2BGR);

return res;
}
Expand Down

0 comments on commit 2a2b23a

Please sign in to comment.