學習如何使用opencv。Chapter 5 透視轉換。摸索 VScode 設定。
Chapter 5 透視轉換
-
getPerspectiveTransform : 四點透視轉換
-
warpPerspective : 矩陣轉圖像
import cv2
import numpy as np
img = cv2.imread("license_plate_number.jpg")
width,height = 76,31
lpn1_o = np.float32([[188,397],[256,399],[189,432],[265,430]])
lpn1_m = np.float32([[0,0],[width,0],[0,height],[width,height]])
matrix = cv2.getPerspectiveTransform(lpn1_o,lpn1_m)
imgOutput = cv2.warpPerspective(img,matrix,(width,height))
imgResize = cv2.resize(imgOutput,(width*3,height*3))
cv2.imshow("Image",img)
cv2.imshow("Image Output",imgOutput)
cv2.imshow("Resize Image",imgResize)
cv2.waitKey(0)
No comments:
Post a Comment