# See the License for the specific language governing permissions and # limitations under the License. # import cv2 import os import sys sys.path.append('.') base_dir = sys.argv[1] from ikalog.utils import IkaGlyphRecoginizer weapons = IkaGlyphRecoginizer() weapons.load_model_from_file('data/weapons.knn.data') weapons.knn_train() results = {} for root, dirs, files in os.walk(base_dir): l = [] for file in files: if file.endswith(".png"): filename = os.path.join(root, file) img = cv2.imread(filename) answer, distance = weapons.match(img) if not (answer in results): results[answer] = [] results[answer].append( { 'filename': filename, 'distance': distance } ) for weapon in sorted(results):