From ecd2b231f55fa913b91fad8929fa5c2b4a929dcf Mon Sep 17 00:00:00 2001
From: Edmond Yoo <hj3yoo@uwaterloo.ca>
Date: Sat, 13 Oct 2018 19:22:57 +0000
Subject: [PATCH] Removing files from AlxeyAB's fork

---
 opencv_dnn.py |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/opencv_dnn.py b/opencv_dnn.py
index 624aea8..9f83caa 100644
--- a/opencv_dnn.py
+++ b/opencv_dnn.py
@@ -9,8 +9,17 @@
 from PIL import Image
 import time
 
+from config import Config
 import fetch_data
-import transform_data
+
+
+"""
+As of the current version, the YOLO network has been removed from this code during optimization.
+It was found out that YOLO was adding too much processing delay, and the benefits from using it couldn't justify
+such heavy cost.
+If you're interested to see the implementation using YOLO, please check out the previous commit:
+https://github.com/hj3yoo/mtg_card_detector/tree/dea64611730c84a59c711c61f7f80948f82bcd31 
+"""
 
 
 def calc_image_hashes(card_pool, save_to=None, hash_size=32, highfreq_factor=4):
@@ -45,7 +54,7 @@
         for card_name in card_names:
             # Fetch the image - name can be found based on the card's information
             card_info['name'] = card_name
-            img_name = '%s/card_img/png/%s/%s_%s.png' % (transform_data.data_dir, card_info['set'],
+            img_name = '%s/card_img/png/%s/%s_%s.png' % (Config.data_dir, card_info['set'],
                                                          card_info['collector_number'],
                                                          fetch_data.get_valid_filename(card_info['name']))
             card_img = cv2.imread(img_name)
@@ -53,7 +62,7 @@
             # If the image doesn't exist, download it from the URL
             if card_img is None:
                 fetch_data.fetch_card_image(card_info,
-                                            out_dir='%s/card_img/png/%s' % (transform_data.data_dir, card_info['set']))
+                                            out_dir='%s/card_img/png/%s' % (Config.data_dir, card_info['set']))
                 card_img = cv2.imread(img_name)
             if card_img is None:
                 print('WARNING: card %s is not found!' % img_name)
@@ -275,7 +284,7 @@
     # Find the contour
     _, cnts, hier = cv2.findContours(img_erode, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
     if len(cnts) == 0:
-        print('no contours')
+        #print('no contours')
         return []
 
     # The hierarchy from cv2.findContours() is similar to a tree: each node has an access to the parent, the first child
@@ -334,7 +343,7 @@
         card_set = key[key.find('(') + 1:key.find(')')]
         confidence = sum(val) / f_len
         card_info = card_pool[(card_pool['name'] == card_name) & (card_pool['set'] == card_set)].iloc[0]
-        img_name = '%s/card_img/tiny/%s/%s_%s.png' % (transform_data.data_dir, card_info['set'],
+        img_name = '%s/card_img/tiny/%s/%s_%s.png' % (Config.data_dir, card_info['set'],
                                                       card_info['collector_number'],
                                                       fetch_data.get_valid_filename(card_info['name']))
         # If the card image is not found, just leave it blank
@@ -533,8 +542,8 @@
     else:
         # Merge database for all cards, then calculate pHash values of each, store them
         df_list = []
-        for set_name in fetch_data.all_set_list:
-            csv_name = '%s/csv/%s.csv' % (transform_data.data_dir, set_name)
+        for set_name in Config.all_set_list:
+            csv_name = '%s/csv/%s.csv' % (Config.data_dir, set_name)
             df = fetch_data.load_all_cards_text(csv_name)
             df_list.append(df)
         card_pool = pd.concat(df_list, sort=True)

--
Gitblit v1.10.0