了解点Point及矩形rectangle函数
示例:绘制医院的红十字
#include <iostream>
#include <opencv2\imgproc\types_c.h> //for CV_RGB2GRAY
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image = Mat::zeros(400, 400, CV_8UC3);
Rect rec1 = Rect(25 , 175 , 350, 50);
Rect rec2 = Rect(175, 25, 50, 350);
rectangle(image, rec1, Scalar(0, 0, 255), -1, 8, 0);
rectangle(image, rec2, Scalar(0, 0, 255), -1, 8, 0);
rectangle(image, Point(25 , 175), Point(375 , 225), Scalar(0, 255, 255), 2, 8, 0);
rectangle(image, Point(175 , 25), Point(225 , 375), Scalar(0, 255, 255), 2, 8, 0);
rectangle(image, Point(175, 175), Point(225, 225), Scalar(0, 0, 255), 3, 8);
imshow("红十字", image);
waitKey();
return 0;
}
运行结果