LabelCheck
ocr.OcrLabelCheckerAPI
OCR 오브젝트의 feasibility 체크를 위한 API입니다.
Usage
# 라벨 체커 빌드.
error, checker = OcrLabelCheckerAPI.build()
sample_ocr_objs = [
{
"polygon": [
[0.0, 0.0],
[15.0, 0.0],
[30.0, 0.0],
[45.0, 0.0],
[45.0, 15.0],
[30.0, 15.0],
[15.0, 15.0],
[0.0, 15.0],
],
"text": "SAMPLE",
}
]
# OCR 오브젝트 리스트에 대한 feasibility 계산.
error, results = checker.apply(sample_ocr_objs)
feasibility, message = results[0]
print(feasibility, message)
체크하는 feasibility의 종류와 순서
- PolygonStructure
- polygon point의 수가 홀수 인 경우
- 하나의 polygon point가 2개의 coordinate를 가지지 않는 경우
- polygon point의 coordinate가 float이 아닌 경우
- PolygonIntersection
- polygon이 서로 교차하는 경우
- SmallSizedPatch
- polygon의 넓이가 10 * text length 보다 작은 경우 (단위: pixel)
- 예시: "SAIGE"의 경우 polygon 넓이가 50보다 작으면 False
- UnreadablePatch
- "text height를 32 pixel로 resize한 text patch"의 width 가 text length * 6 보다 작은 경우
- 예시: "SAIGE"가 적힌 텍스트 패치의 height가 320 pixel이라면, width는 300(=5(320/32)6) 보다 작은 경우 False
- SlantContinuity
- polygon의 top, bottom point로부터 계산한 italic angle 이 불연속한 경우
- 불연속 판단 기준: 인접한 italic angle 의 차이가 60도 이상인 경우 False
build()
classmethod
OcrLabelCheckerAPI를 빌드합니다.
Returns:
| Name | Type | Description |
|---|---|---|
OcrLabelCheckerAPI |
TOcrLabelCheckerAPI
|
빌드된 OcrLabelCheckerAPI |
apply(box_labels)
OCR 오브젝트의 리스트에 대해 각각의 feasibility와 결과 메시지를 리스트로 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box_labels |
List[Dict]
|
OCR 오브젝트 딕셔너리의 리스트입니다. |
required |
Returns:
| Type | Description |
|---|---|
List[Tuple[bool, Union[str, None]]]
|
List[Tuple[bool, str]]: Feasibility를 나타내는 |