이전 게시물을 기억하십니까? 이 답변은 그것에 기초합니다.
그래서 책 주위에 테두리 상자의 4 개의 모서리 점을 얻은 다음이를 호모 그래피 함수에 입력했습니다.
코드 :
#---- 4 corner points of the bounding box
pts_src = np.array([[17.0,0.0], [77.0,5.0], [0.0, 552.0],[53.0, 552.0]])
#---- 4 corner points of the black image you want to impose it on
pts_dst = np.array([[0.0,0.0],[77.0, 0.0],[ 0.0,552.0],[77.0, 552.0]])
#---- forming the black image of specific size
im_dst = np.zeros((552, 77, 3), np.uint8)
#---- Framing the homography matrix
h, status = cv2.findHomography(pts_src, pts_dst)
#---- transforming the image bound in the rectangle to straighten
im_out = cv2.warpPerspective(im, h, (im_dst.shape[1],im_dst.shape[0]))
cv2.imwrite("im_out.jpg", im_out)
![enter image description here](https://i.stack.imgur.com/uchfo.jpg)
이 책의 주위에 경계 상자 윤곽을 가지고 있기 때문에, 그 4 포인트를 pts_src
어레이에 공급해야합니다.
회전 각도를 알고 있거나 rect의 경계점을 알고있는 경우에만 가능합니다. – ZdaR
경계점은 무엇을 의미합니까? – whaangbuu
도서 경계를 경계하는 분홍색 상자 – ZdaR