#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <stdio.h>
using namespace cv;
using namespace std;
RNG rng(12345);
Scalar color[7] = {
(Scalar(0,0,255)),//红色
(Scalar(0,255,0)),//绿色
(Scalar(255,0,0)),//蓝色
(Scalar(255,255,0)),//浅蓝色
(Scalar(255,0,255)),//紫色
(Scalar(0,255,255)),//黄色
(Scalar(128,128,192)),//浅粉色
};
int main()
{
Mat image,img_line,img_rect,img_circle;
image = imread("../test.jpg", 1);
if (image.empty()) {
cout << "无此图片" << endl;
return 0;
}
img_line = image.clone();
img_rect = image.clone();
img_circle = image.clone();
while (1)
{
imshow("原图", image);
waitKey(1);
//直线绘制
line(img_line, Point(100, 100), Point(150, 150), Scalar(0, 0, 255), 3, 8, 0);
line(img_line, Point(200, 200), Point(350, 350), Scalar(0, 0, 255), 3, 8, 0);
imshow("直线绘制", img_line);
waitKey(1);
//矩形绘制
rectangle(img_rect, Rect(300, 300, 100, 200), Scalar(0, 255, 255), 3, 8, 0);
imshow("矩形绘制", img_rect);
waitKey(1);
//圆形绘制
circle(img_circle, Point(200, 200), 50, Scalar(255, 0, 255), 3, 8, 0);
imshow("圆形绘制", img_circle);
waitKey(1);
}
return 1;
}