fix(ocr): allow configuring tesseract path
This commit is contained in:
@@ -51,6 +51,7 @@ SETTINGS = {
|
||||
"exec_max_timeout_s": int(os.getenv("CLICKTHROUGH_EXEC_MAX_TIMEOUT_S", "120")),
|
||||
"exec_max_output_chars": int(os.getenv("CLICKTHROUGH_EXEC_MAX_OUTPUT_CHARS", "20000")),
|
||||
"exec_secret": os.getenv("CLICKTHROUGH_EXEC_SECRET", "").strip(),
|
||||
"tesseract_cmd": os.getenv("CLICKTHROUGH_TESSERACT_CMD", "").strip(),
|
||||
}
|
||||
|
||||
|
||||
@@ -301,6 +302,10 @@ def _import_ocr_libs():
|
||||
import pytesseract
|
||||
from pytesseract import Output
|
||||
|
||||
tesseract_cmd = SETTINGS["tesseract_cmd"]
|
||||
if tesseract_cmd:
|
||||
pytesseract.pytesseract.tesseract_cmd = tesseract_cmd
|
||||
|
||||
return pytesseract, Output
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail=f"ocr backend unavailable: {exc}") from exc
|
||||
|
||||
Reference in New Issue
Block a user