1.1 Related Class
1. Class: OpenCV::CvPoint
CvPoint:表示一个坐标为整数的二维点,是一个包含integer类型成员x和y的结构体。
typdef struct CvPoint { int x; // X axis int y; // Y axis }
2. Class: OpenCV::CvScalar
CvScalar是一个包含四个元素的结构体变量。Element-value (元素)of one pixel. OpenCV supports the image of 4-channels in the maximum. Therefore, CvScalar has 4-values。
typdef struct CvScalar { double val[4]; } CvScalar;
1.2 Sample code
#include <iostream> #include <opencv2/opencv.hpp> //含了OpenCV中各个模块的头文件 must or not able used circle //#include <opencv2/core/core.hpp> //#include <opencv2/highgui/highgui.hpp> using namespace cv; using namespace std; #define height 480 #define width 600 CvPoint CircleCenter; int Radius; CvScalar Color; int Thickness; int Shift; int main() { Mat image(height, width, CV_8UC3, Scalar(255, 255, 255));//(255, 255, 255); white (0, 0, 0) black CircleCenter = cvPoint(100, 100); Radius = 50; Color = CV_RGB(255, 0, 0); Thickness = 3; Shift = 0; circle(image, CircleCenter, Radius, Color, Thickness, Shift); putText(image, // destination image "This is a circle.", // text Point(40, 200), // text position FONT_HERSHEY_PLAIN, // font type 2.0, // font scale 255, // text color (here white) 2); // text thickness namedWindow("yunfung image", WINDOW_NORMAL); imshow("yunfung image", image); waitKey(0); return 0; }