Add QImage and CV::Mat conversion functions into Frame for better handling alpha channel handling
#998
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 introduces enhanced image effect capabilities for the
Frameclass by leveraging the OpenCV library. Direct manipulation ofQImageraw data for complex effects proves challenging, and the performance ofQGraphicsEffectcan 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
QImageandcv::MatinFrame.cpplack alpha channel support, several effects, including the currently implementedOutlineand the proposedShadow, require it for proper rendering. This pull request introduces four new methods to facilitate seamless conversion betweenQImageandcv::Matwhile preserving the alpha channel:QImage2BGRACvMat: Converts aQImageto acv::MatwithBGRApixel format.BGRACvMat2QImage: Converts acv::MatwithBGRApixel format back to aQImage.GetBGRACvMat: Provides access to the underlyingcv::Mat(inBGRAformat) of aFrameobject.SetBGRACvMat: Allows setting thecv::Mat(inBGRAformat) to aFrameobject.These conversion functions were previously located within the
Outlineeffect code and have been migrated to theFrameclass for broader reusability. Your review and feedback on these additions would be greatly appreciated.Note: Theimagecvvariable, which appears to be a potentially unused cachedcv::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_cvvariable.