diff --git a/exp/board_detect.py b/exp/board_detect.py --- a/exp/board_detect.py +++ b/exp/board_detect.py @@ -13,7 +13,6 @@ import scipy.cluster import scipy.ndimage import scipy.signal -from geometry import Line from polar_hough import PolarHough from annotations import DataFile,computeBoundingBox from hough import show,prepareEdgeImg,HoughTransform @@ -73,21 +72,6 @@ def filterStones(contours,bwImg,stoneDim return res -def groupLines(points,minCount,tolerance): - random.shuffle(points) - sample=points[:] - for (i,a) in enumerate(sample): - for (j,b) in enumerate(sample): - if j<=i: continue - ab=Line(a,b) - for c in points: - if c is a or c is b: continue - if point2lineDistance(a,b,c)<=tolerance: - ab.points.add(c) - if len(ab.points)>=minCount: - yield ab - - class BoardDetector: def __init__(self,annotationsPath): self._annotations=DataFile(annotationsPath) @@ -130,9 +114,6 @@ class BoardDetector: hough.update(stonesImg,5) hough.extract() - # # detect lines passing through the stones - # lines=self._constructLines(stones) - # # # detect vanishing points of the lines # imgCenter=EPoint(w//2-x1, h//2-y1) # (a,b,c,d)=(p-EPoint(x1,y1) for p in self._annotations[filename][0]) @@ -191,44 +172,6 @@ class BoardDetector: show(stones,"black and white areas") return stones - def _constructLines(self,stoneLocs): - lineDict=dict() - # minCount=min(max(math.sqrt(len(stoneLocs))-4,3),7) - minCount=6 - log.debug("min count: %s",minCount) - points=[point for (point,contour) in stoneLocs] - for line in groupLines(points,minCount,2): - key=line.getSortedPoints() - if key in lineDict: # we already have a line with the same incident points - continue - lineDict[line.getSortedPoints()]=line - obsolete=set() - for ab in lineDict.values(): - if ab is line: continue - if line.points