Spaces:
Running
Running
Upload 2 files
Browse files
ocr.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys, getopt
|
2 |
+
from OCR import detect
|
3 |
+
|
4 |
+
def main(argv):
|
5 |
+
inputfile = ''
|
6 |
+
outputfile = 'result.txt'
|
7 |
+
try:
|
8 |
+
opts, args = getopt.getopt(argv,"hi:o:m:",["ifile=","ofile=","mode="])
|
9 |
+
except getopt.GetoptError:
|
10 |
+
print ('test.py -i <inputfile> -o <outputfile> -m <mode>')
|
11 |
+
sys.exit(2)
|
12 |
+
for opt, arg in opts:
|
13 |
+
if opt == '-h':
|
14 |
+
print ('test.py -i <inputfile> -o <outputfile> -m <mode>')
|
15 |
+
sys.exit()
|
16 |
+
elif opt in ("-i", "--ifile"):
|
17 |
+
inputfile = arg
|
18 |
+
elif opt in ("-o", "--ofile"):
|
19 |
+
outputfile = arg
|
20 |
+
elif opt in ("-m", "--mode"):
|
21 |
+
mode = arg
|
22 |
+
detect.main(inputfile=inputfile, outputfile=outputfile)
|
23 |
+
if __name__ == "__main__":
|
24 |
+
main(sys.argv[1:])
|