2

I'm interested in setting GPS location metadata to captured images in QML. I noticed the setMetadata(key,value) method in several qml capture elements but I can't understand how it works, or find any examples.

The definition in the documentation states:

"Sets a particular metadata key to value for the subsequent image captures."

http://qt-project.org/doc/qt-5/qml-qtmultimedia-cameracapture.html

Does the method work? if so, please place a simple example. If not, is there any other way to set (or edit) image metadata (even if use of C++ is necessary) in Qt?

Update (but not solved): I've tried the following code, the app runs on desktop takes the picture and saves it. After I open it up with Preview (MAC) and check the metadata... and nothing special there (no comment key).

 Camera {
        id: camera
        captureMode: Camera.CaptureStillImage
        Component.onCompleted: {
            imageCapture.setMetadata("Comment","My Picture")
        }

        imageCapture {
            resolution: "640x480"
            onImageCaptured: {
                console.log("Image Captured Callback : Preview : "+preview)
            }
            onImageSaved: {
                console.log("Image Saved Callback : Save Path : "+path)
            }
            onImageMetadataAvailable: {
                console.log("Image Metadata Callback : "+key+" = "+value)
            }
        }
    }
Gabriel
  • 176
  • 1
  • 12

1 Answers1

1

I think you should use a subset of the keys documented here before you start the capture.

edit

FWIW, here is a minimal test on Ubuntu, Qt 5.3 - I created an empty application, added a menu command, the camera and viewer

import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.0
import QtMultimedia 5.0

ApplicationWindow {
    title: qsTr("Hello World")
    width: 640
    height: 480

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
            MenuItem {
                text: qsTr("Capture")
                onTriggered: {
                    camA.imageCapture.setMetadata("Description", "my comment")
                    camA.imageCapture.captureToLocation("/home/carlo/Pictures/x.jpg")
                }
            }
        }
    }

    Camera { id : camA }
    VideoOutput { source: camA }
}

and the result seems ok...

enter image description here

CapelliC
  • 59,646
  • 5
  • 47
  • 90
  • Hi CapelliC, I've added some code showing what I have tried, using the subset of keys. Is this what you meant? Is the key to be used as a String? It still does not work. On IOS development when I add metadata to a picture I need to add a whole set of keys (not just one) or he simply doesn't add anything to the picture. – Gabriel Jul 12 '14 at 10:11
  • Hi CapelliC, thank you for the sample code. I've created a new project and put the code inside and it has no effect on the picture metadata. Now it's worth mentioning I work on OSX Mavericks(10.9.4). It would be nice if other mac users tried the code on other versions of OSX. Well, maybe its a Mac thing, or even Mavericks/Qt specific issue. The app I'm making is supposed to run on several OS's. I'll try it on Ubuntu as well and see if I get the same results, then Windows, Android and IOS. Post the results here. – Gabriel Jul 13 '14 at 10:20
  • maybe "Comment" isn't a valid JPEG metadata key. Note I used "Description". Effectively, I tried "Comment" before, and that didn't saved my value... The docs clearly state that keys are specific for a format... – CapelliC Jul 13 '14 at 10:34