Skip to content

Bug Report: Incorrect Character Box Order for Inverted Text when return_word_box is enabled #328

@ajaivasudeve

Description

@ajaivasudeve

Description

When processing inverted text using RapidOCR, the OCR engine successfully detects the correct text content (because angle cls is enabled). However, the order of the character-level bounding boxes remains inconsistent with the orientation of the original input text.

For instance:
When the text is inverted (right-to-left in the image), PaddleOCR correctly detects the text as left-to-right in content. However, the character bounding boxes should follow the original right-to-left order of the inverted input.
Conversely, when text is naturally written left-to-right, the bounding boxes are ordered correctly.

This creates confusion when the bounding box coordinates are used for downstream processing or analysis.
Steps to Reproduce

Input an image containing inverted text (right-to-left visually but left-to-right in logical content).
Use RapidOCR to extract character-level bounding boxes and text content.
Observe the order of the bounding boxes:
    The text content is correctly detected as left-to-right.
    However, the character bounding boxes do not match the original input's visual (right-to-left) orientation.

Expected Behavior

For inverted text:

The character-level bounding boxes should follow the original orientation of the text in the input image (right-to-left).
The logical text content can still be left-to-right, as detected.

Actual Behavior

The bounding boxes are incorrectly ordered as left-to-right, regardless of the input text orientation.

Example Data

Input 1:

Original text is inverted (right-to-left).
Bounding box coordinates:

[[[249, 369], [263, 368], [263, 394], [249, 395]],
 [[267, 368], [283, 367], [283, 393], [267, 394]],
 ...
]

Detected content: left-to-right (correct).
Bounding box order: left-to-right (incorrect, should match the input's right-to-left orientation).

Input 2:

Normal left-to-right text.
Bounding box coordinates:

[[[259, 707], [277, 707], [278, 734], [260, 734]],
 [[277, 707], [296, 706], [297, 733], [278, 734]],
 ...
]

Detected content: left-to-right (correct).
Bounding box order: left-to-right (correct).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions