Skip to content

TextSizeCalculator

ocr.OcrTextSizeCalculatorAPI

OCR 오브젝트들의 평균 텍스트 크기를 계산하기 위한 API입니다.

Usage
# 1. OcrTextSizeCalculatorAPI 빌드
error, calculator = OcrTextSizeCalculatorAPI.build()
assert error >= 0, f"[CODE] {error}"

# 2. OCR 오브젝트들의 평균 텍스트 크기 계산
error, mean_text_size = calculator.apply(data=images)

build() classmethod

OcrTextSizeCalculatorAPI 빌드합니다.

Returns:

Name Type Description
OcrTextSizeCalculatorAPI

빌드된 OcrTextSizeCalculatorAPI

apply(data)

OCR 오브젝트들의 평균 텍스트 크기를 계산합니다.

Parameters:

Name Type Description Default
data Dict

data가 담겨 있는 dictionary 입니다.

{
    "{image_id}": {
        "path": Union[str, List[str]],      # 이미지 경로
        "width": int,  # image width
        "height": int,  # image height
        "labels": [
            {
                "polygon": [
                    [point_1_x, point_1_y], # list of float
                    [point_2_x, point_2_y],
                    ...,
                    [point_n_x, point_n_y]
                ],                          # float
                "text": text in box         # str
            },
            ...# times number of labels in the image
        ],
    },
    ...,  # times number of images
}

required

Returns:

Name Type Description
float float

Mean text size of the given data