[Fix] Update cv2.imdecode to use cv2.IMREAD_COLOR for consistent#192
Merged
GreatV merged 1 commit intoPFCCLab:mainfrom Jul 3, 2025
Merged
[Fix] Update cv2.imdecode to use cv2.IMREAD_COLOR for consistent#192GreatV merged 1 commit intoPFCCLab:mainfrom
cv2.imdecode to use cv2.IMREAD_COLOR for consistent#192GreatV merged 1 commit intoPFCCLab:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
1withcv2.IMREAD_COLORacross image-loading methods. - Ensure consistent decode behavior in both
PPOCRLabel.pyandlibs/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 tocv2.IMREAD_UNCHANGED) to preserve alpha channels; switching tocv2.IMREAD_COLORnow discards transparency information. If you need to keep alpha, usecv2.IMREAD_UNCHANGEDinstead ofcv2.IMREAD_COLOR.
)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates multiple methods across the
PPOCRLabel.pyandlibs/autoDialog.pyfiles to improve clarity and maintainability by replacing the hardcoded1parameter incv2.imdecodewith the more descriptivecv2.IMREAD_COLOR. This change ensures better readability and aligns with OpenCV's standard practices.Updates to
cv2.imdecodeusage:1parameter withcv2.IMREAD_COLORin theloadFilemethod to improve code clarity and consistency. (PPOCRLabel.py, PPOCRLabel.pyL2140-R2142)autoRecognition,reRecognition,singleRerecognition, andexpandSelectedShapemethods to usecv2.IMREAD_COLORfor decoding images. (PPOCRLabel.py, [1] [2] [3]saveRecResultmethod to decode images usingcv2.IMREAD_COLORfor consistency with other methods. (PPOCRLabel.py, PPOCRLabel.pyL3498-R3502)runmethod oflibs/autoDialog.pyto maintain uniformity across the codebase. (libs/autoDialog.py, libs/autoDialog.pyL45-R45)