:)
어파인 변환과 투시 변환 본문
한점은 나머지 세 점으로 구할 수 있음.
getRotationMatrix2D : 회전 각도의 개념. 스케일링을 어떻게 할것인가 관점에서 affine을 구함.
getAffineTransform : 세 점을 알고있을때
차선 영상의 버드아이뷰 만들기
- 버드아이뷰(bird`s-eye view)
- 새가 하늘을 내려다보듯이, 매우 높은 곳에 위치한 카메라가 아래의 피사체를 찍은 화면
- 투시 변환을 이용하여 전면에서 촬영된 영상을 버드아이뷰처럼 변환할 수 있음
Mat src;
while (true) {
cap >> src;
if (src.empty())
break;
int w = 500, h = 260;
vector<Point2f> src_pts(4);
vector<Point2f> dst_pts(4);
// 임의의 사다리꼴 좌표를 설정
src_pts[0] = Point2f(474, 400); src_pts[1] = Point2f(710, 400);
src_pts[2] = Point2f(866, 530); src_pts[3] = Point2f(366, 530);
dst_pts[0] = Point2f(0, 0); dst_pts[1] = Point2f(w - 1, 0);
dst_pts[2] = Point2f(w - 1, h - 1); dst_pts[3] = Point2f(0, h - 1);
Mat per_mat = getPerspectiveTransform(src_pts, dst_pts);
Mat dst;
warpPerspective(src, dst, per_mat, Size(w, h));
#if 1
vector<Point> pts;
for (auto pt : src_pts) {
pts.push_back(Point(pt.x, pt.y));
}
polylines(src, pts, true, Scalar(0, 0, 255), 2, LINE_AA);
#endif
imshow("src", src);
imshow("dst", dst);
if (waitKey(10) == 27)
break;
}
'컴퓨터비전' 카테고리의 다른 글
회전 변환과 기하학적 변환의 조합 (0) | 2022.03.22 |
---|---|
크기변환과 보간법 (0) | 2022.03.22 |
이동 변환과 전단 변환 (0) | 2022.03.22 |
영상처리_필터링 (0) | 2022.03.21 |
OpenCV 함수 (0) | 2022.03.20 |
Comments