File size: 986 Bytes
6fc683c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import argparse
import os
import cv2
import tqdm


def convert(fn):
    # given a file name, convert it into binary and store at the same position
    img = cv2.imread(fn)
    gim = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    gim = cv2.adaptiveThreshold(gim, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 45, 11)
    g3im = cv2.cvtColor(gim, cv2.COLOR_GRAY2BGR)
    cv2.imwrite(fn, g3im)



if __name__ == '__main__':
    """
    Now only feasible for trackA_XX
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('--root_dir', default="../datasets/icdar2019/at_trackA_archival")
    args = parser.parse_args()

    for fdname in os.listdir(args.root_dir):
        if fdname.endswith(".json"):
            continue
        ffdname = os.path.join(args.root_dir, fdname)
        for file in tqdm.tqdm(os.listdir(ffdname)):
            if file.endswith(".xml"):
                continue
            ffile = os.path.join(ffdname, file)
            convert(ffile)