fix(perception): disable PaddleOCR doc-unwarping for screenshots
Tests / Test tests.test_device_config.test_device_config_store_settings_get_set_and_defaults failed
Tests / Test tests.test_device_config.test_device_config_store_settings_get_set_and_defaults failed
PaddleOCR's OCR.yaml pipeline defaults to use_doc_orientation_classify
and use_doc_unwarping enabled, which are meant for photographed paper
documents. Applied to a flat, upright device screenshot, UVDoc
geometrically warps the image before detection, and returns box
coordinates in that warped space with no inverse mapping back to the
original image.
Verified on a real screenshot: with unwarping on, the same detected
element ("新项目") shifts from y=158 to y=71 versus the original image,
and 2 boxes near the top edge (status bar time/battery) are dropped
entirely. Disabling both flags by default (still overridable via
explicit kwargs) makes detected boxes match the original screenshot.
This commit is contained in:
+18
-1
@@ -4,7 +4,24 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
from core.models import Bounds
|
||||
from perception.ocr import OCRBox, parse_paddle_result, run_ocr
|
||||
from perception.ocr import OCRBox, PaddleOCREngine, parse_paddle_result, run_ocr
|
||||
|
||||
|
||||
def test_paddle_ocr_engine_disables_doc_preprocessing_by_default() -> None:
|
||||
# Screenshots are flat, upright digital captures, not photographed paper
|
||||
# documents: PaddleOCR's document-unwarping preprocessing has nothing real
|
||||
# to correct and instead warps the image, so detected box coordinates no
|
||||
# longer line up with the original screenshot.
|
||||
engine = PaddleOCREngine(lang="ch")
|
||||
|
||||
assert engine.kwargs["use_doc_orientation_classify"] is False
|
||||
assert engine.kwargs["use_doc_unwarping"] is False
|
||||
|
||||
|
||||
def test_paddle_ocr_engine_lets_callers_override_doc_preprocessing() -> None:
|
||||
engine = PaddleOCREngine(use_doc_unwarping=True)
|
||||
|
||||
assert engine.kwargs["use_doc_unwarping"] is True
|
||||
|
||||
|
||||
def test_parse_paddle_result_accepts_ndarray_fields() -> None:
|
||||
|
||||
Reference in New Issue
Block a user