diff --git a/src/image_analyzer.py b/src/image_analyzer.py --- a/src/image_analyzer.py +++ b/src/image_analyzer.py @@ -1,5 +1,5 @@ import logging -from go import * +from go import Go class ImageAnalyzer: @@ -23,7 +23,7 @@ class ImageAnalyzer: def analyzePoint(self,image,row,col,imageCoords,stoneWidth,stoneHeight): b=w=e=0 - ((x1,y1),(x2,y2))=self.relevantRect(imageCoords,stoneWidth,stoneHeight) + ((x1,y1),(x2,y2))=relevantRect(imageCoords,stoneWidth,stoneHeight) for y in range(y1,y2+1): for x in range(x1,x2+1): @@ -42,13 +42,14 @@ class ImageAnalyzer: if w>=b and w>=e: return Go.WHITE return Go.EMPTY - def relevantRect(self,imageCoords,stoneWidth,stoneHeight): - x=int(imageCoords.x) - y=int(imageCoords.y) - xmax=max(int(stoneWidth*2//7), 2) # !! optimal parameters subject to further research - ymax=max(int(stoneHeight*2//7), 2) - - return ((x-xmax,y-ymax), (x+xmax,y+ymax)) - def setGrid(self,grid): self.grid=grid + + +def relevantRect(imageCoords,stoneWidth,stoneHeight): + x=int(imageCoords.x) + y=int(imageCoords.y) + xmax=max(int(stoneWidth*2//7), 2) # !! optimal parameters subject to further research + ymax=max(int(stoneHeight*2//7), 2) + + return ((x-xmax,y-ymax), (x+xmax,y+ymax))