Skip to content

Add QImage and CV::Mat conversion functions into Frame for better handling alpha channel handling #998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

aperture147
Copy link
Contributor

@aperture147 aperture147 commented Mar 21, 2025

This pull request introduces enhanced image effect capabilities for the Frame class by leveraging the OpenCV library. Direct manipulation of QImage raw data for complex effects proves challenging, and the performance of QGraphicsEffect can be suboptimal. To address these limitations, this PR proposes the integration of OpenCV for more efficient and versatile effect creation.

While existing conversion functions between QImage and cv::Mat in Frame.cpp lack alpha channel support, several effects, including the currently implemented Outline and the proposed Shadow, require it for proper rendering. This pull request introduces four new methods to facilitate seamless conversion between QImage and cv::Mat while preserving the alpha channel:

  • QImage2BGRACvMat: Converts a QImage to a cv::Mat with BGRA pixel format.
  • BGRACvMat2QImage: Converts a cv::Mat with BGRA pixel format back to a QImage.
  • GetBGRACvMat: Provides access to the underlying cv::Mat (in BGRA format) of a Frame object.
  • SetBGRACvMat: Allows setting the cv::Mat (in BGRA format) to a Frame object.

These conversion functions were previously located within the Outline effect code and have been migrated to the Frame class for broader reusability. Your review and feedback on these additions would be greatly appreciated.

Note: The imagecv variable, which appears to be a potentially unused cached cv::Mat, is currently shared across the code. While investigating its purpose, no clear or active usage was identified. The line intended for caching was also commented out. This aspect might warrant further review or potential removal in a subsequent cleanup.

Now switched to brga_image_cv variable.

Copy link

codecov bot commented Mar 22, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 57.35%. Comparing base (7b4e999) to head (985a9df).

Files with missing lines Patch % Lines
src/Frame.cpp 80.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #998      +/-   ##
===========================================
+ Coverage    57.31%   57.35%   +0.04%     
===========================================
  Files          198      198              
  Lines        18166    18189      +23     
===========================================
+ Hits         10412    10433      +21     
- Misses        7754     7756       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant