Example #1
0
    def save_image(self, label):
        if not self.preview:
            pop_up(
                "Mark an image first.",
                "Before you can save an image, you need to take a screenshot (with the take screenshot button),"
                "Then you need to mark the top left corner of the poker window (or load a previously saved one)"
                "After that an image needs to be marked by clicking on the top left and then bottom right corner of that image."
            )
            return

        log.info(f"flattening button {label}")
        self.signal_flatten_button.emit(label)

        self.table_name = self.ui.table_name.currentText()
        mongo = MongoManager()
        owner = mongo.get_table_owner(self.table_name)
        if owner != COMPUTER_NAME:
            pop_up(
                "Not authorized.",
                "You can only edit your own tables. Please create a new copy or start with a new blank table"
            )
            return
        log.info(f"Saving {label}")
        mongo.update_table_image(pil_image=self.preview,
                                 label=label,
                                 table_name=self.table_name)
        log.info("Saving complete")
Example #2
0
def test_card_upload():  # OK!
    mongo = MongoManager()
    table_dict = mongo.get_table('GG_TEST')
    table_scraper = TableScraper(table_dict)
    # table_scraper.screenshot = Image.open(os.path.join(get_dir('tests', 'screenshots'), 'test5.png'))
    # screnshot = table_scraper.crop_from_top_left_corner()
    CARD_VALUES = "23456789TJQKA"
    CARD_SUITES = "CDHS"
    for value in CARD_VALUES:
        for suit in CARD_SUITES:
            fileName = value.upper() + suit.lower() + '.png'
            label = value.lower() + suit.lower()
            pil_image = Image.open(os.path.join('../../../card-detector\\images', fileName))
            mongo.update_table_image(pil_image, label=label, table_name='GG_TEST')