더북(TheBook)

코드 4-7 다양한 도형 그리기 예제 [ch04/drawing]

01    void drawPolys()
02    {
03        Mat img(400, 400, CV_8UC3, Scalar(255, 255, 255));
04     
05        rectangle(img, Rect(50, 50, 100, 50), Scalar(0, 0, 255), 2);
06        rectangle(img, Rect(50, 150, 100, 50), Scalar(0, 0, 128), -1);
07     
08        circle(img, Point(300, 120), 30, Scalar(255, 255, 0), -1, LINE_AA);
09        circle(img, Point(300, 120), 60, Scalar(255, 0, 0), 3, LINE_AA);
10     
11        ellipse(img, Point(120, 300), Size(60, 30), 20, 0, 270, Scalar(255, 255, 0),  -1, LINE_AA);
12        ellipse(img, Point(120, 300), Size(100, 50), 20, 0, 360, Scalar(0, 255, 0), 2, LINE_AA);
13     
14        vector<Point> pts;
15        pts.push_back(Point(250, 250)); pts.push_back(Point(300, 250));
16        pts.push_back(Point(300, 300)); pts.push_back(Point(350, 300));
17        pts.push_back(Point(350, 350)); pts.push_back(Point(250, 350));
18        polylines(img, pts, true, Scalar(255, 0, 255), 2);
19     
20        imshow("img", img);
21        waitKey(0);
22     
23        destroyAllWindows();
24    }

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.