/**
* @function main
* @brief Main function
*/
int main( void )
函数作用:简单几何图形的绘制。
main函数全局调用情况如下:
函数声明情况如下:
函数声明文件如下:
函数流程图如下:
函数逻辑顺序图如下:
函数原始代码如下:
/**
* @function main
* @brief Main function主函数
*/
int main( void ){
//![create_images]创建图像
/// Windows names窗口名称
char atom_window[] = "Drawing 1: Atom";
char rook_window[] = "Drawing 2: Rook";
/// Create black empty images创建黑色的空图
Mat atom_image = Mat::zeros( w, w, CV_8UC3 );
Mat rook_image = Mat::zeros( w, w, CV_8UC3 );
//![create_images]
/// 1. Draw a simple atom: 画一个简单的原子
/// -----------------------
//![draw_atom] 画一个简单的原子
/// 1.a. Creating ellipses创建椭圆
MyEllipse( atom_image, 90 );
MyEllipse( atom_image, 0 );
MyEllipse( atom_image, 45 );
MyEllipse( atom_image, -45 );
/// 1.b. Creating circles创建圆
MyFilledCircle( atom_image, Point( w/2, w/2) );
//![draw_atom] 画一个简单的原子
/// 2. Draw a rook画一辆车
/// ------------------
//![draw_rook] 画一辆车
/// 2.a. Create a convex polygon创建一个凸多边形
MyPolygon( rook_image );
//![rectangle]
/// 2.b. Creating rectangles创建一矩形
rectangle( rook_image,
Point( 0, 7*w/8 ),
Point( w, w),
Scalar( 0, 255, 255 ),
FILLED,
LINE_8 );
//![rectangle]
/// 2.c. Create a few lines画几根线条
MyLine( rook_image, Point( 0, 15*w/16 ), Point( w, 15*w/16 ) );
MyLine( rook_image, Point( w/4, 7*w/8 ), Point( w/4, w ) );
MyLine( rook_image, Point( w/2, 7*w/8 ), Point( w/2, w ) );
MyLine( rook_image, Point( 3*w/4, 7*w/8 ), Point( 3*w/4, w ) );
//![draw_rook]
/// 3. Display your stuff!显示作品
imshow( atom_window, atom_image );
moveWindow( atom_window, 0, 200 );
imshow( rook_window, rook_image );
moveWindow( rook_window, w, 200 );
waitKey( 0 );等待按键
return(0);
}