SpeedProg
2019-09-06 f347391e8ea3a837860c894d9c21e93550039f32
opencv_dnn.py
old mode 100644 new mode 100755
@@ -28,7 +28,7 @@
    new_pool = pd.DataFrame(columns=list(card_pool.columns.values))
    for hs in hash_size:
        new_pool['card_hash_%d' % hs] = np.NaN
        new_pool['set_hash_%d' % hs] = np.NaN
        new_pool['set_hash_%d' % 64] = np.NaN
        #new_pool['art_hash_%d' % hs] = np.NaN
    for ind, card_info in card_pool.iterrows():
        if ind % 100 == 0:
@@ -91,9 +91,9 @@
            img_set = Image.fromarray(set_img)
            for hs in hash_size:
                card_hash = ih.phash(img_card, hash_size=hs)
                set_hash = ih.whash(img_set, hash_size=hs)
                set_hash = ih.whash(img_set, hash_size=64)
                card_info['card_hash_%d' % hs] = card_hash
                card_info['set_hash_%d' % hs] = set_hash
                card_info['set_hash_%d' % 64] = set_hash
                #print('Setting set_hash_%d' % hs)
                #art_hash = ih.phash(img_art, hash_size=hs)
                #card_info['art_hash_%d' % hs] = art_hash
@@ -113,8 +113,8 @@
    elif isinstance(hash_size, int):
        hash_size = [hash_size]
    num_cores = 15
    num_partitions = round(card_pool.shape[0]/100)
    num_cores = 16
    num_partitions = round(card_pool.shape[0]/1000)
    if num_partitions < min(num_cores, card_pool.shape[0]):
        num_partitions = min(num_cores, card_pool.shape[0])
    pool = Pool(num_cores)
@@ -462,7 +462,7 @@
                print('Idx:', ix, 'Name:', cd['name'], 'Set:', cd['set'], 'Diff:', top_matches[ix])
            cd_data['set_hash_diff'] = cd_data['set_hash_%d' % hash_size]
            cd_data['set_hash_diff'] = cd_data['set_hash_%d' % 64]
            cd_data['set_hash_diff'] = cd_data['set_hash_diff'].apply(lambda x: np.count_nonzero(x != set_img_hash))
            conf = sorted(cd_data['set_hash_diff'])
            print('Confs:', conf)
@@ -654,7 +654,7 @@
        card_pool.drop('Unnamed: 0', axis=1, inplace=True, errors='ignore')
        card_pool = calc_image_hashes(card_pool, save_to=pck_path, hash_size=hash_sizes)
    ch_key = 'card_hash_%d' % args.hash_size
    set_key = 'set_hash_%d' % args.hash_size
    set_key = 'set_hash_%d' % 64
    if ch_key not in card_pool.columns:
        # we did not generate this hash_size yet
        print('We need to add hash_size=%d' % (args.hash_size,))
@@ -696,6 +696,8 @@
        if test_ext in ['jpg', 'jpeg', 'bmp', 'png', 'tiff']:
            # Test file is an image
            img = cv2.imread(args.in_path)
            if img is None:
                print('Could not read', args.in_path)
            detect_frame(img, card_pool, hash_size=args.hash_size, out_path=out_path, display=args.display,
                         debug=args.debug)
        else: