티스토리 뷰
728x90
반응형
1. 두 개의 네모를 회전 시켜주세요.
2. 두 개의 네모를 포함한 bounding 입니다.
3. bounding 네모를 그려주세요.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include "pch.h" #include <iostream> #include <opencv2/opencv.hpp> using namespace cv; using namespace std; int main() { for (int deg = 0; deg < 50000; deg += 1) { Mat image(800, 800, CV_8UC1, Scalar(255)); Point2f center(250, 200), pts[4]; // 첫번째 사각형 센터 Point2f center2(600, 400), pts2[4]; // 두번째 사각형 센터 Size2f size(300, 100); // 첫번째 사각형 가로, 세로 Size2f size2(200, 50); // 두번째 사각형 가로, 세로 RotatedRect rot_rect(center, size, deg);// 3번째 인자 각도 RotatedRect rot_rect2(center2, size2, deg);// 3번째 인자 각도 Rect bound_rect = rot_rect.boundingRect(); Rect bound_rect2 = rot_rect2.boundingRect(); rectangle(image, bound_rect, Scalar(0), 3); rectangle(image, bound_rect2, Scalar(0), 3); rectangle(image, bound_rect | bound_rect2, Scalar(0), 3); circle(image, rot_rect.center, 1, Scalar(0), 2); circle(image, rot_rect2.center, 1, Scalar(0), 2); rot_rect.points(pts); rot_rect2.points(pts2); for (int i = 0; i < 4; i++) { circle(image, pts[i], 4, Scalar(5), 1); // 3번째 인자 두께 circle(image, pts2[i], 4, Scalar(5), 1); // 3번째 인자 두께 line(image, pts[i], pts[(i + 1) % 4], Scalar(0), 4); line(image, pts2[i], pts2[(i + 1) % 4], Scalar(0), 4); } imshow("회전사각형", image); waitKey(10); } return 0; } | cs |
반응형
'C, C++ > openCV' 카테고리의 다른 글
C/C++ openCV 사용자가 클릭한 3개의 점을 지나는 포물선 그리기 (1) | 2019.05.02 |
---|---|
C/C++ openCV 두개 네모 회전 및 바운딩영역 (2) | 2019.03.19 |
티스토리 방명록
- Total
- 134,602
- Today
- 1
- Yesterday
- 33
Blog is powered by
Tistory / Designed by
Tistory
Contact: j0n9m1n1@gmail.com
Contact: j0n9m1n1@gmail.com