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. QtQuick / QML / Display MJPEG Image Stream - QImages - from C++
QtWS25 Last Chance

QtQuick / QML / Display MJPEG Image Stream - QImages - from C++

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 6.3k Views
  • 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.
  • W Offline
    W Offline
    werispaul
    wrote on 11 Oct 2013, 08:08 last edited by
    #1

    Hi Qt community,

    i'm locking for a convenient way to display QImages in a QtQuick / QML Scene. Images are provided by a MJPEG Stream received via a C++ module.

    I've identified several ways to do this so far, but am unsure what the best solution, in sense of performance, would be.

    • Using QImageProvider, disabling cache and emitting an update Signal from C++ on image change
    • Re-implement a QQuickItem using UpdatePaintNodeData() ( drawing via QSGGeometry )
    • Re-implement a QQuickPaintedItem using paint()

    Thanks in advance for sharing your experience.

    S 1 Reply Last reply 1 Jul 2016, 17:11
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 11 Oct 2013, 10:35 last edited by
      #2

      I'm afraid my answer will not be terribly reassuring: all 3 ways are correct and valid :)

      I think the QImageProvider is the most "official" way to do it, and it may help in other places, too (all functionalities of QML Image component will still work, while when reimplementing QQItem you need to provide all the functionality yourself).

      (Z(:^

      1 Reply Last reply
      0
      • W Offline
        W Offline
        werispaul
        wrote on 14 Oct 2013, 10:04 last edited by
        #3

        A not completely unexpected answer. ;)

        I decided to use the ImageProvider and it seems to work fine, at least with a 40ms update rate. Currently I'm using signal/slot to force the image refresh on the QML side, is there a nicer way to do this?

        @onUpdateImg {
        var oldSource = img.source;
        img.source = "";
        img.source = oldSource;
        }@

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 14 Oct 2013, 11:07 last edited by
          #4

          You can touch sourceSize property instead (it causes the image to be reloaded), but that is not in any way nicer than your solution.

          (Z(:^

          1 Reply Last reply
          0
          • D Offline
            D Offline
            deion
            wrote on 18 Oct 2013, 10:26 last edited by
            #5

            In one of my projects, SmartCam - http://sourceforge.net/projects/smartcam , I chose to use the approach of overriding the paint() method of QDeclarativeItem (Qt 4.x)
            I always wondered why such a basic scenario (changing the provided image) was not supported in QImageProvider and one needed to use ugly hacks for this.

            You can get the source code for SmartCam, the Qt/QML client is for BB10.

            Regards,
            Ionut

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 18 Oct 2013, 13:14 last edited by
              #6

              Perhaps Movie and AnimatedImage components are the answer, but I have never looked into those, so I can't say much about them.

              (Z(:^

              1 Reply Last reply
              0
              • W werispaul
                11 Oct 2013, 08:08

                Hi Qt community,

                i'm locking for a convenient way to display QImages in a QtQuick / QML Scene. Images are provided by a MJPEG Stream received via a C++ module.

                I've identified several ways to do this so far, but am unsure what the best solution, in sense of performance, would be.

                • Using QImageProvider, disabling cache and emitting an update Signal from C++ on image change
                • Re-implement a QQuickItem using UpdatePaintNodeData() ( drawing via QSGGeometry )
                • Re-implement a QQuickPaintedItem using paint()

                Thanks in advance for sharing your experience.

                S Offline
                S Offline
                seyed
                wrote on 1 Jul 2016, 17:11 last edited by
                #7

                @werispaul I know this is an very old post, but I submitting this reply post for anybody interested about it.
                In my experience this scenario should be done using second option.
                As you noticed, QImageProvider is not suitable for periodical update. Also notifying update from C++ to C++ through QML is a bad idea!
                Last option has some performance impact since it is for older version of QtQuick and is not recommended any more (if possible) although it is more simple..
                Therefore you should use second option :)

                1 Reply Last reply
                1

                • Login

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