Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Cannot safe image on android with camera
Forum Updated to NodeBB v4.3 + New Features

Cannot safe image on android with camera

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
13 Posts 4 Posters 1.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sandro4912
    wrote on last edited by
    #3

    stupid question. How can I change to a different path? What would be a valid path?

    jsulmJ 1 Reply Last reply
    0
    • S sandro4912

      stupid question. How can I change to a different path? What would be a valid path?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @sandro4912 See https://doc.qt.io/qt-5/qstandardpaths.html using it you can get the paths @sierdzio already mentioned

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      2
      • jsulmJ jsulm

        @sandro4912 See https://doc.qt.io/qt-5/qstandardpaths.html using it you can get the paths @sierdzio already mentioned

        S Offline
        S Offline
        sandro4912
        wrote on last edited by
        #5

        @jsulm So I have to make a C++ class with QStandardPaths or is it available directly in QML?

        jsulmJ 1 Reply Last reply
        0
        • S sandro4912

          @jsulm So I have to make a C++ class with QStandardPaths or is it available directly in QML?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @sandro4912 There is something in Qt Labs: https://doc.qt.io/qt-5/qml-qt-labs-platform-standardpaths.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • S Offline
            S Offline
            sandro4912
            wrote on last edited by
            #7

            I tryed it with the path but still no images. show up. Atleast the error does not appear anymore.

            I changed the path here.

            delegate: Image {
                        height: 100
                        //source: path
                        source: Labs.StandardPaths.writableLocation(Labs.StandardPaths.ApplicationsLocation)
                        fillMode: Image.PreserveAspectFit
                    }
            

            Full code:

            import QtQuick 2.14
            import QtQuick.Controls 2.14
            import QtMultimedia 5.14
            import Qt.labs.platform 1.1 as Labs
            
            ApplicationWindow {
                visible: true
            
                id: root
            
                width: 1024
                height: 600
            
            
            
            Rectangle {
                width: parent.width
                height: parent.height
            
                color: "black"
            
                VideoOutput {
                    anchors.fill: parent
                    source: camera
                }
            
                Camera {
                    id: camera
                }
            
                ListModel {
                    id: imagePaths
                }
            
                ListView {
                    id: listView
            
                    anchors.left: parent.left
                    anchors.right: parent.right
                    anchors.bottom: parent.bottom
                    anchors.bottomMargin: 10
            
                    height: 100
            
                    orientation: ListView.Horizontal
                    spacing: 10
            
                    model: imagePaths
            
                    delegate: Image {
                        height: 100
                        //source: path
                        source: Labs.StandardPaths.writableLocation(Labs.StandardPaths.ApplicationsLocation)
                        fillMode: Image.PreserveAspectFit
                    }
            
                    Rectangle {
                        anchors.fill: parent
                        anchors.topMargin: -10
            
                        color: "black"
                        opacity: 0.5
                    }
                }
            
                Image {
                    id: image
                    anchors.fill: parent
                }
            
                Connections {
                    target: camera.imageCapture
            
                    onImageSaved: {
                        imagePaths.append({"path": path})
                        listView.positionViewAtEnd();
                    }
                }
            
                Column {
                    id: buttons
            
                    anchors.top: parent.top
                    anchors.right: parent.right
                    anchors.margins: 10
            
                    spacing: 10
            
                    Button {
                        id: shotButton
            
                        text: "Take Photo"
                        onClicked: {
                            camera.imageCapture.capture();
                        }
                    }
            
                    Button {
                        id: playButton
            
                        text: "Play Sequence"
                        onClicked: {
                            parent.parent.startPlayback();
                        }
                    }
            
                    Button {
                        id: clearButton
            
                        text: "ClearSequence"
                        onClicked: {
                            imagePaths.clear()
                        }
                    }
                }
            
                property int _imageIndex: -1
            
                function startPlayback()
                {
                    root.state = "playing"
                    setImageIndex(0);
                    playTimer.start();
                }
            
                function setImageIndex(i)
                {
                    _imageIndex = i;
            
                    if(_imageIndex >= 0 && _imageIndex < imagePaths.count) {
                        image.source = imagePaths.get(_imageIndex).path;
                    }
                    else {
                        image.source = "";
                    }
                }
            
                Timer {
                    id: playTimer
            
                    interval: 200
                    repeat: false
            
                    onTriggered: {
                        if (_imageIndex + 1 < imagePaths.count) {
                            setImageIndex(_imageIndex + 1);
                            playTimer.start();
                        }
                        else {
                            setImageIndex(-1);
                            root.state = "";
                        }
                    }
                }
            
                states: [
                    State {
                        name: "playing"
                        PropertyChanges {
                            target: buttons
                            opacity: 0
                        }
                        PropertyChanges {
                            target: listView
                            opacity: 0
                        }
                    }
                ]
            
                transitions: [
                    Transition {
                        PropertyAnimation { properties: "opacity"; duration: 200; }
                    }
                ]
            }
            
            }
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              Hi,

              Did you check that the folder exist ?
              The path returned by QStandardPaths will be valid but you have to create some of these folders on first use.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • S Offline
                S Offline
                sandro4912
                wrote on last edited by
                #9

                What do you mean by that I have to create the standard folder?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  Check if the folder exist and if not well create it before creating the image file.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    sandro4912
                    wrote on last edited by
                    #11

                    how could I achieve that in the code above?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      Create the folder ? I would do that in the C++ part on startup using QDir.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • S Offline
                        S Offline
                        sandro4912
                        wrote on last edited by
                        #13

                        I think the path should already exist since it is the ApplicationsLocation.

                        I tryed this:

                            Camera {
                                id: camera
                            }
                            ListModel {
                                id: imagePaths
                            }
                        
                        ```
                        ListView {
                            id: listView
                        
                            //...
                        
                            model: imagePaths
                        
                            delegate: Image {
                                height: 100
                                source: path
                                fillMode: Image.PreserveAspectFit
                            }
                        
                            Rectangle {
                                anchors.fill: parent
                                anchors.topMargin: -10
                        
                                color: "black"
                                opacity: 0.5
                            }
                        }
                        
                        
                            ```
                        Image {
                                id: image
                                anchors.fill: parent
                            }
                        
                            Connections {
                                target: camera.imageCapture
                        
                                onImageSaved: {
                                    imagePaths.append({"path": Labs.StandardPaths.writableLocation(Labs.StandardPaths.ApplicationsLocation)})
                                    listView.positionViewAtEnd();
                                }
                            }
                        

                        So my idea was when camera takes the picture i append in the model imagePaths the ApplicationsLocation Path.

                        Then when the delegate is used in the view it should load the Image from path.

                        If I try this it sayes QJSValue is not convertible to QDir

                        So what is wrong here?

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved