1 #include <highgui.h> 2 #include <cv.h> 3 #include <stdio.h> 4 5 #pragma comment (lib,"opencv_calib3d231d.lib") 6 #pragma comment (lib,"opencv_contrib231d.lib") 7 #pragma comment (lib,"opencv_core231d.lib") 8 #pragma comment (lib,"opencv_features2d231d.lib") 9 #pragma comment (lib,"opencv_flann231d.lib") 10 #pragma comment (lib,"opencv_gpu231d.lib") 11 #pragma comment (lib,"opencv_haartraining_engined.lib") 12 #pragma comment (lib,"opencv_highgui231d.lib") 13 #pragma comment (lib,"opencv_imgproc231d.lib") 14 #pragma comment (lib,"opencv_legacy231d.lib") 15 #pragma comment (lib,"opencv_ml231d.lib") 16 #pragma comment (lib,"opencv_objdetect231d.lib") 17 #pragma comment (lib,"opencv_ts231d.lib") 18 #pragma comment (lib,"opencv_video231d.lib") 19 20 #define ROWS 400 21 #define COLS 400 22 23 /* 24 *《学习OpenCV》第三章第二题 25 * 完成时间:0:22 3/2 星期六 2013 26 */ 27 int main() 28 { 29 // 创造一个三通道二维矩阵,大小为ROWS*COLS 30 CvMat* mat = cvCreateMat(ROWS, COLS, CV_8UC3); 31 32 // 将所有数值初始化为零 33 for ( int i = 0 ; i < mat->cols; i++ ) 34 { 35 for ( int j = 0 ;j < mat->rows; j++ ) 36 { 37 cvSet2D(mat, i, j, cvScalarAll( 0 )); 38 } 39 } 40 41 // 画一个圆 42 cvCircle(mat, cvPoint(ROWS/ 2 , COLS/ 2 ), ROWS/ 4 , cvScalar( 255 , 255 , 0 ), 3 , 8 , 0 ); 43 44 // 显示图像 45 cvShowImage( " img " , mat); 46 cvWaitKey( 0 ); 47 48 cvReleaseMat(& mat); 49 cvDestroyAllWindows(); 50 51 return 0 ; 52 }
运行结果: