@@ -30,7 +30,7 @@ inline std::vector<cv::Scalar> toCvScalarColors(const std::vector<std::array<int
30
30
}
31
31
32
32
inline 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,
34
34
const std::vector<std::string>& allClassNames = {})
35
35
{
36
36
assert (bboxes.size () == classIndices.size ());
@@ -63,7 +63,7 @@ inline cv::Mat visualizeOneImage(const cv::Mat& img, const std::vector<std::arra
63
63
64
64
inline cv::Mat visualizeOneImageWithMask (const cv::Mat& img, const std::vector<std::array<float , 4 >>& bboxes,
65
65
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,
67
67
const std::vector<std::string>& allClassNames = {},
68
68
const float maskThreshold = 0.5 )
69
69
{
@@ -116,4 +116,16 @@ inline cv::Mat visualizeOneImageWithMask(const cv::Mat& img, const std::vector<s
116
116
117
117
return result;
118
118
}
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
+ }
119
131
} // namespace
0 commit comments