diff --git a/src/image_analyzer.py b/src/image_analyzer.py --- a/src/image_analyzer.py +++ b/src/image_analyzer.py @@ -1,12 +1,13 @@ import logging as log from grid import Grid -from go import Go +from go import exportBoard +import go class ImageAnalyzer: def __init__(self,tresB=30,tresW=60): - self.board=[[Go.EMPTY]*19 for r in range(19)] + self.board=[[go.EMPTY]*19 for r in range(19)] self.grid=None self.tresB=tresB @@ -24,8 +25,7 @@ class ImageAnalyzer: self.board[r][c]=self.analyzePoint(image,r,c,intersection,*(self.grid.stoneSizeAt(r,c))) - boardStr="\n".join(str(row) for row in self.board) - log.info("board analyzed:\n%s",boardStr) + log.info("board analyzed:\n%s", exportBoard(self.board)) def analyzePoint(self,image,row,col,imageCoords,stoneWidth,stoneHeight): b=w=e=0 @@ -45,9 +45,9 @@ class ImageAnalyzer: 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 + if b>=w and b>=e: return go.BLACK + if w>=b and w>=e: return go.WHITE + return go.EMPTY def setGridCorners(self,corners): self.grid=Grid(corners)