diff --git a/src/image_analyzer.py b/src/image_analyzer.py --- a/src/image_analyzer.py +++ b/src/image_analyzer.py @@ -1,4 +1,5 @@ -import logging +import logging as log +from grid import Grid from go import Go @@ -11,14 +12,15 @@ class ImageAnalyzer: self.tresB=tresB self.tresW=tresW - def analyze(self,image,sizeCoef,shift): + # let's not concern ourselves with sizecoef and shift here anymore. we want corners to come already properly recomputed + def analyze(self,image): if self.grid==None: return False for r in range(19): for c in range(19): intersection=self.grid.intersections[r][c] - self.board[r][c]=self.analyzePoint(image,r,c,intersection*sizeCoef+shift,*(self.grid.stoneSizeAt(r,c,sizeCoef))) + self.board[r][c]=self.analyzePoint(image,r,c,intersection,*(self.grid.stoneSizeAt(r,c))) def analyzePoint(self,image,row,col,imageCoords,stoneWidth,stoneHeight): b=w=e=0 @@ -36,14 +38,14 @@ class ImageAnalyzer: elif 100*I>self.tresW: w+=1 else: e+=1 - logging.debug("(%d,%d) ... (b=%d,w=%d,e=%d)", row, col, b, w, e) + log.debug("(%d,%d) ... (b=%d,w=%d,e=%d)", row, col, b, w, e) if b>=w and b>=e: return Go.BLACK if w>=b and w>=e: return Go.WHITE return Go.EMPTY - def setGrid(self,grid): - self.grid=grid + def setGridCorners(self,corners): + self.grid=Grid(corners) def relevantRect(imageCoords,stoneWidth,stoneHeight):