Move app settings into config files
This commit is contained in:
@@ -14,8 +14,7 @@ from PIL import Image
|
||||
from PIL import ImageFilter
|
||||
from PIL import ImageOps
|
||||
|
||||
from common.env_config import getEnvBool
|
||||
from common.env_config import getEnvFloat
|
||||
from common.config_loader import loadOcrConfig
|
||||
from common.runtime_log import appendRuntimeLog
|
||||
from screen.screen_actions import captureOcrRegion
|
||||
|
||||
@@ -32,9 +31,10 @@ def getOcrEngine():
|
||||
|
||||
if _ocr_engine is None:
|
||||
log("INFO", "PaddleOCR initializing")
|
||||
config = loadOcrConfig()
|
||||
options = {
|
||||
"lang": "japan",
|
||||
"use_angle_cls": getEnvBool("OCR_USE_ANGLE_CLS", False),
|
||||
"use_angle_cls": config["use_angle_cls"],
|
||||
"show_log": False,
|
||||
}
|
||||
|
||||
@@ -112,7 +112,8 @@ def printOcrResult(text):
|
||||
|
||||
|
||||
def preprocessOcrImage(image_path):
|
||||
enabled = getEnvBool("OCR_PREPROCESS", True)
|
||||
config = loadOcrConfig()
|
||||
enabled = config["preprocess"]
|
||||
if not enabled:
|
||||
return image_path
|
||||
|
||||
@@ -122,7 +123,7 @@ def preprocessOcrImage(image_path):
|
||||
image = ImageOps.autocontrast(image)
|
||||
image = image.filter(ImageFilter.SHARPEN)
|
||||
|
||||
scale = max(1.0, min(2.0, getEnvFloat("OCR_SCALE", 1.5)))
|
||||
scale = max(1.0, min(2.0, config["scale"]))
|
||||
if scale > 1.0:
|
||||
width, height = image.size
|
||||
resampling = getattr(
|
||||
|
||||
Reference in New Issue
Block a user