def get_cards(self, show_tqdm=True): """Find and classify cards from game image.""" card_ims_with_corners = find_cards(self.filename, with_corners=True) for im, corner in card_ims_with_corners: self.cards.append(Card(im, corner)) card_iter = tqdm(self.cards) if show_tqdm else self.cards for card in card_iter: card.label = classify_card_from_im(card.im)
def main(): """For each of the given filenames, show each card found and allow the user to label the file, then save it in the output directory. """ for filename in IN_FILENAMES: cards = card_finder.find_cards(filename) for card in cards: label_and_save(card)
def test_card_finder_e2e(self): game_num = 7 card_count = 12 game_file = cf.game_img_filename(game_num) cards = list(cf.find_cards(game_file)) self.assertEqual(len(cards), card_count) cf.write_cards(cards, out_dir=TMP_DIR) self.assertEqual(len(os.listdir(TMP_DIR)), card_count)