Fix: Handle grayscale image matching with RGB templates matching#5700
Open
ycnliu wants to merge 4 commits into
Open
Fix: Handle grayscale image matching with RGB templates matching#5700ycnliu wants to merge 4 commits into
ycnliu wants to merge 4 commits into
Conversation
Add: Event Alliance Before the Hagiobull (event_20260520_cn)
Fixed OpenCV matchTemplate assertion error when matching RGB template frames against grayscale images. The error occurred in campaign OCR when TEMPLATE_STAGE_CLEAR_20240725 (GIF with RGB frames) was matched against grayscale stage images. Changes: - Added automatic grayscale conversion of templates when input image is grayscale in Template.match_multi() - Handles both GIF and non-GIF templates - Prevents cv2.error: (-215:Assertion failed) type mismatch
Owner
|
Convert TEMPLATE_STAGE_CLEAR_20240725 to grayscale image instead. Converting channels internally may have bad performance and hard to notice |
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.
Fixes the OpenCV matchTemplate assertion error when matching RGB template frames against grayscale images.
Issue
Campaign OCR fails with error:
cv2.error: (-215:Assertion failed) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2
This occurs when
TEMPLATE_STAGE_CLEAR_20240725(GIF with RGB frames) is matched against grayscale stage images incampaign_extract_name_image().Changes
Template.match_multi()Testing
The fix ensures that when a grayscale image is passed to
match_multi(), any RGB templates are automatically converted to grayscalebefore matching.