【发布时间】:2015-08-23 04:09:28
【问题描述】:
我正在开发车牌检测算法。 我做了板块本地化,现在出现了新问题。 我想检测板图像旋转角度并在必要时旋转。 但是如何检测呢? 我尝试使用 cv2.HoughLinesP 函数,但结果如附图所示 http://postimg.org/image/vis8errzn/
y = area.shape[0]
x = area.shape[1]
#############################################################################
#If necessary rotate image by angle detected with Hough transformation
gray = cv2.cvtColor(area,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,50,150,apertureSize = 3)
minLineLength = 10
maxLineGap = 30
lines = cv2.HoughLinesP(edges,1,math.pi/180,100,minLineLength,maxLineGap)
if(lines != None):
for x1,y1,x2,y2 in lines[0]:
cv2.line(gray,(x1,y1),(x2,y2),(0,255,0),2)
a = ((y2-y1)*1.0)/((x2-x1)*1.0)
print 'a = ', a
print 'lines = ', lines
【问题讨论】:
-
我认为您正在寻找这样的东西。 felix.abecassis.me/2011/09/opencv-detect-skew-angle
标签: python image algorithm opencv image-processing