Reputation: 300
Is there a way in QML to render the output of an effect(eg. Fastblur) to an external image? I would like to use this in conjunction with a videooutput for a something like real-time snapchat filters.
In my app, the camera feeds the videooutput which feeds the effect output but there doesn't seem to be an API for rendering the effect to an image. The imageCapture camera component only captures the frame from directly from the camera before the effect is applied. There's no method in the effect component to render it to an external image.
Is there a way to do this?
Upvotes: 0
Views: 998
Reputation: 49319
There is a grabToImage()
method that's available for every QML visual item, and it works for QtGraphicalEffects
as well.
It is not very efficient tho, but in most cases it will suffice. Note that it will save individual images tho, it is not usable for video, and while Qt itself can internally encode video, it doesn't really offer anything in terms of video encoding of individual frames as a public API, so if you want to save the effect output as a video, you will have to dig in deeper into the scene-graph to implement a more efficient method for frame capturing, and utilize some 3rd party library to encode the frames to video.
Upvotes: 1