I'm writing an Ubuntu Touch QML app that captures and processes images from a camera device. The processing is done by a C++ plugin to which I'm passing the URL of the image.
I can successfully save images and load them from the C++ plugin, but I'd rather not have to save the images on the filesystem first, and pass the in-memory camera preview to the plugin instead.
Given the URL for the preview that I'm getting from the camera (image://camera/preview_1
), I'm guessing I should be able to get a reference to the "camera"
image provider and then use the requestImage() method to get the image.
However, I've not been able to figure out how to get hold of the camera
image provider. Here's the code:
QString Decoder::decodeImageQML(const QUrl &imgUrl)
{
/*
* @imgUrl: URL to the camera preview. E.g. image://camera/preview_1
*/
QQmlEngine * engine;
QQuickImageProvider *imageProvider = 0;
// FIXME: this does not work, I'm not sure how to get hold of
// the image provider
imageProvider = engine->imageProvider("camera");
QImage image = imageProvider->requestImage(("preview_1", &size, QSize());
return Decoder::decodeImage(image);
}
How do I get a reference to the camera
image provider?