Page 970 - 3-3
P. 970
# 단위를 'radian' 으로 바꾼다
M=None
# 기울여야하는 각도를 저장하기위한 변수
if roFlag:
center=(plateList[0][0],plateList[0][1])
# 센터를 지정
M=cv2.getRotationMatrix2D(center,atan,1)
# 다음 방향으로 atan 만큼 기울인다
else:
center=(plateList[3][0],plateList[3][0])
# 센터를 지정
M=cv2.getRotationMatrix2D(center,-atan,1)
# 다음 방향으로 -atan 만큼 기울인다
num_rows,num_cols=image.shape[:2]
#image 의 0 번과 1 번을 각각 저장한다
dst=cv2.warpAffine(ori2,M,(num_cols,num_rows))
# 최종적으로 각도를 조정
startPos=()
# 최종적인 번호판 부분의 왼쪽 위 좌표
endPos=()
# 최종적인 번호판 부분의 오른쪽 아래 좌표
#y 좌표에 따라서 변경
if plateList[0][1] < plateList[3][1]:
startPos=(int(round(plateList[0][0]+plateList[0][2]*2.2))
,int(round(plateList[0][1]-plateList[0][3]*0.5)))
endPos=(int(round(-plateList[0][0]-plateList[0][2]+plateList[3][0]*1.99))
,int(round(plateList[3][1]+plateList[3][3]*1.5)))
else:
startPos=(int(round(plateList[0][0]+plateList[0][2]*2.2))
,int(round(plateList[3][1]-plateList[3][3]*0.5)))
endPos=(int(round(-plateList[0][0]-plateList[0][2]+plateList[3][0]*1.96))
,int(round(plateList[0][1]+plateList[0][3]*1.5)))
crop=dst[startPos[1]:endPos[1],endPos[0]:startPos[0]]
# 얻어낸 좌표에서 추출
ret,gb=defCap.filter(crop2)
#crop2 를 필터링하여 gb 에저장
ret,labels,stats,centroids=cv2.connectedComponentsWithStats(gb)
#gb 를 넣어 사각형값으로 반환받아 좌표값을 받음
- 970 -