I made a hough transform for car plate recognition. I found some vertical and horizontal lines. I need to make an algorithm such that it will choose the right rectangle shape.
I tried to control it with edge map so I can only draw with pixel value 255 but couldnt figure it out.
def extract_hough_lines( local_maximas,diag_lenx,edges,row,col):
lines = []
for theta_ind, rho_ind in zip(local_maximas[0], local_maximas[1]):
x1,y1,x2,y2=0,0,0,0
rho =int(round(rho_ind - diag_lenx))
theta = np.deg2rad(theta_ind)
x0, y0 = 0,0
cos_t, sin_t = np.cos(theta), np.sin(theta)
if theta_ind==0:
# dogru dik
x0, y0 = rho, 0
elif theta_ind==90:
# dogru paralel
x0, y0 = 0, rho
else:
x0 =int(round(cos_t * rho))
y0 =int(round(sin_t * rho))
x1 = int(round(x0 + 1000 * (-sin_t)))
y1 = int(round(y0 + 1000 * (cos_t)))
x2 = int(round(x0 - 1000 * (-sin_t)))
y2 = int(round(y0 - 1000 * (cos_t)))
lines.append((theta, rho, (x1, y1), (x2, y2)))
return lines