Opencv-solver/Sudoku_extractor.py
def extract_digit(self, img, rect, x, y):
        """Extracts a digit (if one exists) from a Sudoku square."""

        digit = self.cut_from_rect(img, rect)  # Get the digit box from the whole square
        # plt.imshow(digit)
        # plt.show()

        # Use fill feature finding to get the largest feature in middle of the box
        # Margin used to define an area in the middle we would expect to find a pixel belonging to the digit
        h, w = digit.shape[:2]
        margin = int(np.mean([h, w]) / 2.5)
        self.find_largest_feature(digit, [margin, margin], [w - margin, h - margin], x, y)
Extracts a digit (if one exists) from a Sudoku square.
Extracts a digit (if one exists) from a Sudoku square.
Extracts a digit ( if one exists ) from a Sudoku square .
def extract_digit(self, img, rect, x, y):
        digit = self.cut_from_rect(img, rect)  
        h, w = digit.shape[:2]
        margin = int(np.mean([h, w]) / 2.5)
        self.find_largest_feature(digit, [margin, margin], [w - margin, h - margin], x, y)
def extract_digit ( self , img , rect , x , y ) : digit = self . cut_from_rect ( img , rect ) h , w = digit . shape [ : 2 ] margin = int ( np . mean ( [ h , w ] ) / 2.5 ) self . find_largest_feature ( digit , [ margin , margin ] , [ w - margin , h - margin ] , x , y )
Extracts a digit (if one exists) from a Sudoku square.
Extracts a digit ( if one exists ) from a Sudoku square .
"""Extracts a digit (if one exists) from a Sudoku square.""" # Get the digit box from the whole square # plt.imshow(digit) # plt.show() # Use fill feature finding to get the largest feature in middle of the box # Margin used to define an area in the middle we would expect to find a pixel belonging to the digit
self
img
rect
x
y