Skip to content

[Fix] Update image decoding and processing in Worker class#193

Merged
GreatV merged 1 commit intoPFCCLab:mainfrom
GreatV:fixbug_1
Jul 3, 2025
Merged

[Fix] Update image decoding and processing in Worker class#193
GreatV merged 1 commit intoPFCCLab:mainfrom
GreatV:fixbug_1

Conversation

@GreatV
Copy link
Collaborator

@GreatV GreatV commented Jul 3, 2025

This pull request includes updates to improve the functionality and accuracy of OCR processing in the PPOCRLabel and autoDialog modules. The key changes involve modifying configuration parameters and fixing how images are handled during OCR prediction.

Changes to OCR configuration:

  • In PPOCRLabel.py, the get_str method now sets the use_textline_orientation parameter to False, disabling textline orientation detection. This change likely reflects a shift in how text orientation is handled in the OCR pipeline.

Fixes to image handling:

  • In libs/autoDialog.py, the run method now ensures that images are properly decoded before shape extraction and OCR prediction. The cv2.imdecode function's output is stored in a variable (img) before accessing its shape, and the decoded image itself is passed to the OCR prediction method instead of the file path. This improves the robustness of the image processing workflow.

Copilot AI review requested due to automatic review settings July 3, 2025 13:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refines OCR image handling in libs/autoDialog.py for robustness and adjusts OCR orientation settings in PPOCRLabel.py.

  • Disable textline orientation detection in OCR configuration to streamline orientation handling.
  • Decode images into memory before extracting dimensions and passing them to OCR, improving error handling.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
libs/autoDialog.py Decode image to img variable, extract shape, and pass img to OCR instead of file path
PPOCRLabel.py Set use_textline_orientation to False in OCR parameters
Comments suppressed due to low confidence (1)

libs/autoDialog.py:48

  • [nitpick] Consider adding unit tests for both branches of this size check (images smaller and larger than 32×32) to verify correct handling of edge cases.
                        if h > 32 and w > 32:

img = cv2.imdecode(
np.fromfile(img_path, dtype=np.uint8), cv2.IMREAD_COLOR
).shape
)
Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cv2.imdecode can return None when decoding fails; add a check for img is None before accessing img.shape to avoid runtime errors.

Suggested change
)
)
if img is None:
logger.warning("Failed to decode image: %s", img_path)
self.result_dic = None
continue

Copilot uses AI. Check for mistakes.
@GreatV GreatV linked an issue Jul 3, 2025 that may be closed by this pull request
@GreatV GreatV merged commit aef495c into PFCCLab:main Jul 3, 2025
1 check passed
@GreatV GreatV deleted the fixbug_1 branch July 3, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

导出的识别结果图片不对,是个斜的,怎么回事啊?

2 participants