def __init__(self, image, lineFinderBuilder): self.image = image self.imageWidth = image.shape[1] self.imageHeight = image.shape[0] self.centerY = self.imageHeight / 2 self.centerX = self.imageWidth / 2 commandPanelLineFinder = CommandPanelLineFinder(image, lineFinderBuilder) self.horizontalLines, self.verticalLines = commandPanelLineFinder.findLines(applyCorrection=False)
def findCommand(self, commandPanelImage, row, column): commandPanelLineFinder = CommandPanelLineFinder(commandPanelImage, self.lineFinderBuilder) lines = commandPanelLineFinder.findLines() perspectiveMethod = RectanglePerspectiveMethod(self.getTemplateSize()) commandPanelSquareExtractor = CommandPanelSquareExtractor(commandPanelImage, lines, perspectiveMethod) commandPanelImage = commandPanelSquareExtractor.extractSquare(row, column) commandPanelCellTemplateComparator = CommandPanelCellTemplateComparator(commandPanelImage, self.templates) if self.commandPanelNumber == self.LETTER_COMMAND_PANEL_NUMBER: command = commandPanelCellTemplateComparator.findLetter() else: if (row, column) in self.DIRECTION_COMMAND_CORRECT_CELL: command = commandPanelCellTemplateComparator.findDirection() else: command = '_' return command