Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. get camera frame on Android (PC is ok)
Qt 6.11 is out! See what's new in the release blog

get camera frame on Android (PC is ok)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
11 Posts 3 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    IIRC, on Android the the QVideoFrame contains a texture. You should check the QAbstractVideoBuffer::HandleType of it.

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

    B 2 Replies Last reply
    0
    • SGaistS SGaist

      Hi and welcome to devnet,

      IIRC, on Android the the QVideoFrame contains a texture. You should check the QAbstractVideoBuffer::HandleType of it.

      B Offline
      B Offline
      bigbao
      wrote on last edited by
      #3

      @SGaist
      Thank you very much, I still don't quite understand what I should do, can you give me a simple example?

      1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        IIRC, on Android the the QVideoFrame contains a texture. You should check the QAbstractVideoBuffer::HandleType of it.

        B Offline
        B Offline
        bigbao
        wrote on last edited by
        #4

        @SGaist
        did you mean like this:(This is someone else's code, I don't know what it does, and there is the usage of the handleType you mentioned.)
        QListQVideoFrame::PixelFormat supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
        {
        Q_UNUSED(handleType);
        return QListQVideoFrame::PixelFormat()
        << QVideoFrame::Format_ARGB32
        << QVideoFrame::Format_ARGB32_Premultiplied
        << QVideoFrame::Format_RGB32
        << QVideoFrame::Format_RGB24
        << QVideoFrame::Format_RGB565
        << QVideoFrame::Format_RGB555
        << QVideoFrame::Format_ARGB8565_Premultiplied
        << QVideoFrame::Format_BGRA32
        << QVideoFrame::Format_BGRA32_Premultiplied
        << QVideoFrame::Format_BGR32
        << QVideoFrame::Format_BGR24
        << QVideoFrame::Format_BGR565
        << QVideoFrame::Format_BGR555
        << QVideoFrame::Format_BGRA5658_Premultiplied
        << QVideoFrame::Format_AYUV444
        << QVideoFrame::Format_AYUV444_Premultiplied
        << QVideoFrame::Format_YUV444
        << QVideoFrame::Format_YUV420P
        << QVideoFrame::Format_YV12
        << QVideoFrame::Format_UYVY
        << QVideoFrame::Format_YUYV
        << QVideoFrame::Format_NV12
        << QVideoFrame::Format_NV21
        << QVideoFrame::Format_IMC1
        << QVideoFrame::Format_IMC2
        << QVideoFrame::Format_IMC3
        << QVideoFrame::Format_IMC4
        << QVideoFrame::Format_Y8
        << QVideoFrame::Format_Y16
        << QVideoFrame::Format_Jpeg
        << QVideoFrame::Format_CameraRaw
        << QVideoFrame::Format_AdobeDng;
        }

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

          No, rather qDebug() << frame.handleType().

          In any case, you should take a look at this project which implements a QVideoFilterRunnable which handles video frame also on Android.

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

          B 3 Replies Last reply
          0
          • SGaistS SGaist

            No, rather qDebug() << frame.handleType().

            In any case, you should take a look at this project which implements a QVideoFilterRunnable which handles video frame also on Android.

            B Offline
            B Offline
            bigbao
            wrote on last edited by
            #6

            @SGaist
            thank you very much.
            it's ok. thanks.

            1 Reply Last reply
            0
            • SGaistS SGaist

              No, rather qDebug() << frame.handleType().

              In any case, you should take a look at this project which implements a QVideoFilterRunnable which handles video frame also on Android.

              B Offline
              B Offline
              bigbao
              wrote on last edited by
              #7

              @SGaist
              sorry I don't know how to change " UNSOLVED" to " SOLVED"

              VRoninV 1 Reply Last reply
              0
              • B bigbao

                @SGaist
                sorry I don't know how to change " UNSOLVED" to " SOLVED"

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #8

                @bigbao said in get camera frame on Android (PC is ok):

                how to change " UNSOLVED" to " SOLVED"

                https://forum.qt.io/topic/71830/hitchhiker-s-visual-guide-to-the-qt-forum

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                0
                • SGaistS SGaist

                  No, rather qDebug() << frame.handleType().

                  In any case, you should take a look at this project which implements a QVideoFilterRunnable which handles video frame also on Android.

                  B Offline
                  B Offline
                  bigbao
                  wrote on last edited by bigbao
                  #9

                  @SGaist
                  Hi, in thant code,I want to know supportedViewfinderResolutions of camera,so the main.qml is:

                  ApplicationWindow {
                  visible: true
                  width: 640
                  height: 480
                  title: qsTr("My Video Filter")

                  Camera {
                      id: camera
                      //viewfinder.resolution: "320x240"
                      //viewfinder.resolution: "600x400"
                  }
                  
                  VideoOutput {
                      id: videoOutput
                  
                      anchors.fill: parent
                  
                      autoOrientation: true
                      source: camera
                      filters: [ videoFilter ]
                  }
                  
                  MyVideoFilter {
                      id: videoFilter
                  
                      orientation: videoOutput.orientation
                  }
                  
                  MouseArea{
                      id: mousearea
                      anchors.fill: parent
                      onClicked: show_frame_rate()
                  }
                  
                  function show_frame_rate()
                  {
                      console.log(camera.viewfinder.resolution)
                      console.log(camera.viewfinder.supportedViewfinderResolutions)
                      //there is problem:
                      /* print
                      qml: QSize(-1, -1)
                      qml: undefined
                       */
                  }
                  

                  }

                  I don't konw why , I can't get :
                  print info:
                  qml: QSize(-1, -1)
                  qml: undefined
                  is it possible to get those info in my filter:
                  class MyVideoFilterRunnable : public QVideoFilterRunnable
                  {
                  public:
                  MyVideoFilterRunnable(MyVideoFilter* parent = nullptr);

                  QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) Q_DECL_OVERRIDE;
                  QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags, QImage image);
                  

                  protected:
                  MyVideoFilter* m_Filter;
                  int m_Orientation;
                  int m_Flip;
                  };

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

                    The backend might have some limitation there.

                    Out of curiosity, what do you need these values for ?

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

                    B 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      The backend might have some limitation there.

                      Out of curiosity, what do you need these values for ?

                      B Offline
                      B Offline
                      bigbao
                      wrote on last edited by
                      #11

                      @SGaist
                      I know these resolutions and choose one of them I need.
                      thanks

                      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