I would like to do something like this for example:
constexpr std::array<cv::Vec3b, 6> COLORS {
cv::Vec3b(0, 255, 0), // green
cv::Vec3b(255, 0, 0), // blue
cv::Vec3b(0, 0, 255), // red
cv::Vec3b(0, 255, 255), // yellow
cv::Vec3b(255, 0, 255), // magenta
cv::Vec3b(255, 255, 0) // cyan
}
However, cv::Vec3b cannot be made constexpr, is there support for constexpr containers in opencv? Or another way around this?
Compiler error:
error: the type ‘const std::vector<cv::Vec<unsigned char, 3> >’ of ‘constexpr’ variable ‘COLORS’ is not literal
};
As current, std::vector can't be used with constexpr initialisation outside of a constexpr function as any dynamic memory used is only valid within the constexpr function.