Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. QtonPi
  4. How to get video preview from QProcess to fill a rectangle in qml
Forum Updated to NodeBB v4.3 + New Features

How to get video preview from QProcess to fill a rectangle in qml

Scheduled Pinned Locked Moved Unsolved QtonPi
9 Posts 2 Posters 2.5k Views 1 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.
  • KachorazaK Offline
    KachorazaK Offline
    Kachoraza
    wrote on last edited by
    #1

    Hi!
    I have a c++ class, where I am initiating QProcess in detached mode. This process launches a python script to get raspberry pi camera preview.
    How can I get that preview and show it in a rectangle element?
    The c++ function is a void type. Should it be some other type? You can make a QString function to return a QString, but there is no QProcess type.
    I would appreciate any help. Thanks

    Pablo J. RoginaP 1 Reply Last reply
    0
    • KachorazaK Kachoraza

      Hi!
      I have a c++ class, where I am initiating QProcess in detached mode. This process launches a python script to get raspberry pi camera preview.
      How can I get that preview and show it in a rectangle element?
      The c++ function is a void type. Should it be some other type? You can make a QString function to return a QString, but there is no QProcess type.
      I would appreciate any help. Thanks

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @Kachoraza you should provide more details about your runtime environment, i.e.
      is the python script running on the RPi device, or is just connecting remotely?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • KachorazaK Offline
        KachorazaK Offline
        Kachoraza
        wrote on last edited by
        #3

        the python script is running on the pi.yes the python script is running on the pi locally.

        Pablo J. RoginaP 1 Reply Last reply
        0
        • KachorazaK Kachoraza

          the python script is running on the pi.yes the python script is running on the pi locally.

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @Kachoraza and what about the Qt application using QProcess?

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • KachorazaK Offline
            KachorazaK Offline
            Kachoraza
            wrote on last edited by
            #5

            it is also running locally on the pi

            Pablo J. RoginaP 1 Reply Last reply
            0
            • KachorazaK Kachoraza

              it is also running locally on the pi

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @Kachoraza so what about driving the Pi camera directly from your QML app? just for instance this guide

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • KachorazaK Offline
                KachorazaK Offline
                Kachoraza
                wrote on last edited by
                #7

                thanks. I will check it

                1 Reply Last reply
                0
                • KachorazaK Offline
                  KachorazaK Offline
                  Kachoraza
                  wrote on last edited by
                  #8

                  I tried to access the camera through Camera element and VideoOutput element. Camera status is 2, which I cannot understand.
                  Camera {
                  id: mycamera

                      Component.onCompleted: {
                          console.log(cameraStatus);
                          mycamera.start()
                          console.log(cameraStatus);
                      }
                  
                  }
                  

                  I tried it on pi and on ubuntu as well

                  1 Reply Last reply
                  0
                  • KachorazaK Offline
                    KachorazaK Offline
                    Kachoraza
                    wrote on last edited by Kachoraza
                    #9

                    @Pablo-J-Rogina I am trying to get camera preview with the following code, but all I have is a white window. Can you please see what am I doing wrong here. I have tried it on pi and ubuntu with no errors, but similar result. Thanks in advance
                    import QtQuick 2.9
                    import QtQuick.Window 2.3
                    import QtMultimedia 5.9
                    import QtQuick.Controls 2.2

                    Window {
                    id: window
                    width: 640
                    height: 480
                    property alias window: window
                    property alias videooutput: videooutput
                    visible: true
                    property Camera camera: Camera {
                    id: camera
                    captureMode: Camera.CaptureViewfinder
                    cameraState: Camera.ActiveState
                    Component.onCompleted: {
                    camera.start()
                    if(cameraState === Camera.ActiveState){
                    console.log("Camera ready")
                    }
                    }
                    }
                    VideoOutput {
                    id: videooutput
                    anchors.fill: parent
                    source: camera
                    focus: visible
                    enabled: true
                    Component.onCompleted: {
                    console.log(camera.cameraState)
                    }
                    }
                    }

                    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