diff --git a/exp/hough.py b/exp/hough.py --- a/exp/hough.py +++ b/exp/hough.py @@ -10,6 +10,8 @@ import scipy.optimize import scipy.signal import cv2 as cv +from geometry import EPoint,Line + DEBUG=True @@ -45,15 +47,25 @@ class HoughTransform: def extract(self): img=self._createImg() self.show(img) - (ab,cd)=self._detectLines() + lines=self._detectLines() + res=[] i=0 - for (score,alpha,beta,peaks) in (ab,cd): + for (score,alpha,beta,peaks) in lines: log.debug("score: %s",score) log.debug("alpha, beta: %s, %s",alpha,beta) self._drawLine(img,alpha,beta,peaks,i) + + keys=self._readLineKeys(alpha,beta) + for k in peaks: + (alphaDeg,d)=keys[k] + alphaRad=alphaDeg*math.pi/180 + baseLine=Line(alphaRad,0) + dd=baseLine.distanceTo(EPoint(*self._center)) # to shift d from the center to 0,0 + res.append(Line(alphaRad, dd+d-self._diagLen//2)) i+=1 self.show(img) + return res def update(self,img,weight=1): start=datetime.now().timestamp()