-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
53 lines (38 loc) · 1.37 KB
/
config.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
from utils.offset import Offset
class Config:
TEMP_PATH = os.environ["USERPROFILE"] + "\\AppData\\Local\\Temp"
OCR_AUTOMATION_TEMP_FOLDER = "OcrAutomation"
OCR_WORKING_DIR = os.path.join(TEMP_PATH, OCR_AUTOMATION_TEMP_FOLDER)
OCR_EDITOR_LNK_PATH = (
'"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\'
'ABBYY FineReader PDF 15\\ABBYY FineReader 15 OCR-Editor.lnk"'
)
DPI = 600
CROP_Y_AXIS_THRESHOLD = 0.95
MIN_DPI = 72
MAX_DPI = 900
VERSION = "1.3.5"
STOP_STUCK_RUNNING = False
MIN_PEN_WIDTH = 3
MAX_PEN_WIDTH = 50
DEFAULT_CROP_BOX_OFFSET = Offset(top=5, right=5, bottom=10, left=5)
IMAGE_SETTINGS_ENABLED = None
METADATA_IS_ENABLED = False
PREVIOUS_RUN_WAS_COMPLETE_PROCEDURE = None
AUTHOR_DB_NAME = "authors.sqlite"
@staticmethod
def initialize_directories() -> None:
"""
Initializes needed directories
"""
if not os.path.exists(Config.OCR_WORKING_DIR):
os.makedirs(Config.OCR_WORKING_DIR)
@staticmethod
def map_dpi_to_pen_width(dpi_value: int):
return round(
Config.MIN_PEN_WIDTH
+ (dpi_value - Config.MIN_DPI)
* (Config.MAX_PEN_WIDTH - Config.MIN_PEN_WIDTH)
/ (Config.MAX_DPI - Config.MIN_DPI)
)