绘制圆 /* 绘制圆 */
Scalar color = Scalar(255, 0, 255);
Point center = Point(src.cols / 2, src.rows / 2);
circle(src, center, 150, color, 1, 8);
绘制文字 Mat src;
src = imread("E:/1.png"); putText(src,"hellowopenCV",Point(10,100),CV_FONT_HERSHEY_COMPLEX,1.0,Scalar(12,23,200),3,8);
imshow("output image",src);
waitKey(0);
绘制随机直线 Mat src;
src = imread("E:/1.png");
RNG rng(12345);
Point p1;
Point p2;
Mat bg = Mat::zeros(src.size(), src.type());
while (1)
{
for (int i = 0; i < 10000; i++)
{
p1.x = rng.uniform(0, src.cols);
p1.y = rng.uniform(0, src.rows);
p2.x = rng.uniform(0, src.cols);
p2.y = rng.uniform(0, src.rows);
Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
line(bg, p1, p2, color, 1, 8);
imshow("input", bg);
if (waitKey(50) > 0)
{
break;
}
}
}
效果图:
|