查找车牌内的旋转角度

时间:2018-12-20 11:12:03

标签: image image-processing rotation

我正在尝试纠正车牌内的变形,例如:

Distorted license plates

但是,我找不到检测旋转角度的可靠方法。我试图将特征值用作here,但失败了。

我也在考虑霍夫线检测,但结果仍然很差。

我该怎么做才能改善旋转检测?

1 个答案:

答案 0 :(得分:0)

找到板轮廓,然后通过cv2.minAreaRect

查找板的角度
#preprocessing steps
...
#find angle
im2, contours, hierarchy = cv2.findContours(preprocessed_sloping_plate,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

#contour with the largest area is possibly the plate
max_area = 0
max_cnt = None
for cnt in contours:
    area = cv2.contourArea(cnt)
    if(area > max_area):
        max_area = area 
        max_cnt = cnt

min_rect = cv2.minAreaRect(max_cnt)
(x,y,w,h,angle) = min_rect

#rotate
M = cv2.getRotationMatrix2D((w/2, h/2), angle, 1.0)
rotated_plate = cv2.warpAffine(preprocessed_sloping_plate, M, (w,h))