def execute_HoughLines(proxy,obj):
''' find houghlines '''
# parameter from obj
canny1=obj.canny1
canny2=obj.canny2
rho=obj.rho
theta=obj.theta
threshold=obj.threshold
minLineLength =obj.minLineLength
maxLineGap =obj.maxLineGap
# load the image
try: img=obj.sourceObject.Proxy.img.copy()
except: img=cv2.imread(__dir__+'/icons/freek.png')
# find edges
# naechst zwei zeilen koennen wahrscheinlich weg. #+#
edges = cv2.Canny(img,canny1,canny2)
obj.Proxy.img = cv2.cvtColor(edges, cv2.COLOR_GRAY2RGB)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,canny1,canny2)
xsize=img.shape[1]
ysize=img.shape[0]
# find lines
lines = cv2.HoughLinesP(edges,1,np.pi/180*theta,threshold, minLineLength = minLineLength, maxLineGap = maxLineGap)
k=0
fclines=[]
img = 0 *img
for l in lines:
k += 1
[[x1,y1,x2,y2]] = l
fl=tools.fcline(x1,-y1,x2,-y2)
fclines.append(fl)
print (x1,y1,x2,y2)
a=cv2.line(img,(x1,y1),(x2,y2),(0,255,0),1)
# data for following nodes
obj.Proxy.img=img
obj.Proxy.fclines=fclines
obj.Proxy.lines=lines
# method for extra calculations
obj.Proxy.__class__.linelengths=property(lambda self: linelengths(self))
obj.Proxy.__class__.directions=property(lambda self: directions(self))
评论列表
文章目录