Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Open
wants to merge 8 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 54.94%. Comparing base (e76a3de) to head (f2f76e0).

Files with missing lines Patch % Lines
src/Frame.cpp 80.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #998      +/-   ##
===========================================
+ Coverage    54.89%   54.94%   +0.05%     
===========================================
  Files          185      185              
  Lines        16800    16823      +23     
===========================================
+ Hits          9222     9244      +22     
- Misses        7578     7579       +1     

☔ 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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant