Skip to content

[Fix] Update cv2.imdecode to use cv2.IMREAD_COLOR for consistent#192

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

[Fix] Update cv2.imdecode to use cv2.IMREAD_COLOR for consistent#192
GreatV merged 1 commit intoPFCCLab:mainfrom
GreatV:bug_fix

Conversation

@GreatV
Copy link
Collaborator

@GreatV GreatV commented Jul 3, 2025

This pull request updates multiple methods across the PPOCRLabel.py and libs/autoDialog.py files to improve clarity and maintainability by replacing the hardcoded 1 parameter in cv2.imdecode with the more descriptive cv2.IMREAD_COLOR. This change ensures better readability and aligns with OpenCV's standard practices.

Updates to cv2.imdecode usage:

  • Replaced the 1 parameter with cv2.IMREAD_COLOR in the loadFile method to improve code clarity and consistency. (PPOCRLabel.py, PPOCRLabel.pyL2140-R2142)
  • Updated the autoRecognition, reRecognition, singleRerecognition, and expandSelectedShape methods to use cv2.IMREAD_COLOR for decoding images. (PPOCRLabel.py, [1] [2] [3]
  • Modified the saveRecResult method to decode images using cv2.IMREAD_COLOR for consistency with other methods. (PPOCRLabel.py, PPOCRLabel.pyL3498-R3502)
  • Applied the same replacement in the run method of libs/autoDialog.py to maintain uniformity across the codebase. (libs/autoDialog.py, libs/autoDialog.pyL45-R45)

Copilot AI review requested due to automatic review settings July 3, 2025 13:03
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 replaces hardcoded decode flags in cv2.imdecode calls with the descriptive cv2.IMREAD_COLOR constant to improve readability and align with OpenCV best practices.

  • Swap magic number 1 with cv2.IMREAD_COLOR across image-loading methods.
  • Ensure consistent decode behavior in both PPOCRLabel.py and libs/autoDialog.py.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
libs/autoDialog.py Replaced 1 with cv2.IMREAD_COLOR in run image decode
PPOCRLabel.py Updated several methods (loadFile, reRecognition, singleRerecognition, expandSelectedShape, saveRecResult) to use cv2.IMREAD_COLOR
Comments suppressed due to low confidence (1)

PPOCRLabel.py:3502

  • The original code used -1 (which corresponds to cv2.IMREAD_UNCHANGED) to preserve alpha channels; switching to cv2.IMREAD_COLOR now discards transparency information. If you need to keep alpha, use cv2.IMREAD_UNCHANGED instead of cv2.IMREAD_COLOR.
                    )

@GreatV GreatV merged commit 624da4f into PFCCLab:main Jul 3, 2025
1 check passed
@GreatV GreatV deleted the bug_fix branch July 3, 2025 13:05
@GreatV GreatV linked an issue Jul 3, 2025 that may be closed by this pull request
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