OpenCV随机颜色,用于画图调试
static Scalar randomColor(int64 seed) { RNG rng(seed); int icolor = (unsigned)rng; return Scalar(icolor & 255, (icolor >> 8) & 255, (icolor >> 16) & 255); }
一种推荐的做法是,使用opencv自己的时间函数作为随机数的种子。
cv::line(dst, cv::Point(x, y), cv::Point(x2, y2), randomColor(cv::getTickCount()), 2);