cpp
Mat bg = Mat::zeros(Size(512,512), CV_8UC3);
int w = bg.cols;
int h = bg.rows;
RNG rng(12345);
while (true)
{
int c = cv::waitKey(10);
if (c == 27) {
break;
}
int x1 = rng.uniform(0, w);
int y1 = rng.uniform(0, h);
int x2 = rng.uniform(0, w);
int y2 = rng.uniform(0, h);
bg = Scalar(0, 0, 0);
line(bg, Point(x1, y1), Point(x2, y2), Scalar(rng.uniform(0,255), rng.uniform(0, 255), rng.uniform(0, 255)), 2, LINE_AA, 0);
imshow("Draw_random", bg);
}
推荐一个零声学院项目课,个人觉得老师讲得不错,分享给大家:
零声白金学习卡(含基础架构/高性能存储/golang云原生/音视频/Linux内核)
https://xxetb.xet.tech/s/3Zqhgt