@@ -30,7 +30,7 @@ inline std::vector<cv::Scalar> toCvScalarColors(const std::vector<std::array<int
3030}
3131
3232inline cv::Mat visualizeOneImage (const cv::Mat& img, const std::vector<std::array<float , 4 >>& bboxes,
33- const std::vector<uint64_t >& classIndices, const std::vector<cv::Scalar> allColors,
33+ const std::vector<uint64_t >& classIndices, const std::vector<cv::Scalar>& allColors,
3434 const std::vector<std::string>& allClassNames = {})
3535{
3636 assert (bboxes.size () == classIndices.size ());
@@ -63,7 +63,7 @@ inline cv::Mat visualizeOneImage(const cv::Mat& img, const std::vector<std::arra
6363
6464inline cv::Mat visualizeOneImageWithMask (const cv::Mat& img, const std::vector<std::array<float , 4 >>& bboxes,
6565 const std::vector<uint64_t >& classIndices, const std::vector<cv::Mat>& masks,
66- const std::vector<cv::Scalar> allColors,
66+ const std::vector<cv::Scalar>& allColors,
6767 const std::vector<std::string>& allClassNames = {},
6868 const float maskThreshold = 0.5 )
6969{
@@ -116,4 +116,16 @@ inline cv::Mat visualizeOneImageWithMask(const cv::Mat& img, const std::vector<s
116116
117117 return result;
118118}
119+
120+ cv::Mat drawColorChart (const std::vector<std::string>& classes, const std::vector<cv::Scalar>& colors)
121+ {
122+ cv::Mat legend = cv::Mat::zeros ((classes.size () * 25 ) + 25 , 300 , CV_8UC (3 ));
123+ for (std::size_t i = 0 ; i < classes.size (); ++i) {
124+ cv::putText (legend, classes[i], cv::Point (5 , (i * 25 ) + 17 ), cv::FONT_HERSHEY_SIMPLEX, 0.5 ,
125+ cv::Scalar (0 , 0 , 255 ), 2 );
126+ cv::rectangle (legend, cv::Point (100 , (i * 25 )), cv::Point (300 , (i * 25 ) + 25 ), colors[i], -1 );
127+ }
128+
129+ return legend;
130+ }
119131} // namespace
0 commit comments