Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWidget Flickering for frame by frame streaming of video

QWidget Flickering for frame by frame streaming of video

Scheduled Pinned Locked Moved Solved General and Desktop
qwidgetqpainteventflickeringvideopixmap
26 Posts 5 Posters 11.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.
  • S SGaist
    13 Mar 2018, 22:27

    See QImage::rgbSwapped

    S Offline
    S Offline
    SilverSurfer
    wrote on 24 May 2018, 12:53 last edited by
    #17

    @SGaist
    QImage::rgbSwapped results in creating new QImage with is equivalent to deep copy. So It does not help. Is there any other way to dislaying the RGB planes correctly ?

    Note: Whenever I write the contents of the buffer to a file with appropriate headers I could see the Image correctly when I open the Image through windows photo viewer.

    Original Problem Statement : Display Byte Buffer(uchar*) to a QWidget without the need to deep Copy .

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 May 2018, 18:19 last edited by
      #18

      Where are these frames coming from ?

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

      S 1 Reply Last reply 25 May 2018, 15:35
      0
      • S SGaist
        24 May 2018, 18:19

        Where are these frames coming from ?

        S Offline
        S Offline
        SilverSurfer
        wrote on 25 May 2018, 15:35 last edited by
        #19

        @SGaist

        These frames are received from a server.

        //Api that talks to server
        fetchBitmap(&vector[0]);
        

        I do not have access to server code.

        P.S: Server Machine is Linux and Client is Windows . Could this be the reason for RGB /BGR mismatch ?

        M 1 Reply Last reply 25 May 2018, 16:29
        0
        • W Offline
          W Offline
          wrosecrans
          wrote on 25 May 2018, 16:27 last edited by
          #20

          Is there any chance of the paint event being triggered by the system at a moment when the pixmap isn't fully populated? If that is possible, you would get flickering regardless of whether the load function is faster or slower than real time.

          1 Reply Last reply
          1
          • S SilverSurfer
            25 May 2018, 15:35

            @SGaist

            These frames are received from a server.

            //Api that talks to server
            fetchBitmap(&vector[0]);
            

            I do not have access to server code.

            P.S: Server Machine is Linux and Client is Windows . Could this be the reason for RGB /BGR mismatch ?

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 25 May 2018, 16:29 last edited by
            #21

            @SilverSurfer said in QWidget Flickering for frame by frame streaming of video:

            Could this be the reason for RGB /BGR mismatch ?

            Well there is always Endianness but if using same sort of CPU in both ends, its likely not related to that.

            S 1 Reply Last reply 28 May 2018, 07:46
            0
            • M mrjj
              25 May 2018, 16:29

              @SilverSurfer said in QWidget Flickering for frame by frame streaming of video:

              Could this be the reason for RGB /BGR mismatch ?

              Well there is always Endianness but if using same sort of CPU in both ends, its likely not related to that.

              S Offline
              S Offline
              SilverSurfer
              wrote on 28 May 2018, 07:46 last edited by
              #22

              @mrjj
              Both machines are little endian.

              M 1 Reply Last reply 28 May 2018, 08:51
              0
              • S SilverSurfer
                28 May 2018, 07:46

                @mrjj
                Both machines are little endian.

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 28 May 2018, 08:51 last edited by
                #23

                @SilverSurfer
                Ok. so most likely they
                are just using openCV and send as BGR888

                So i dont see any way to convert to supported format without copy.

                W 1 Reply Last reply 29 May 2018, 01:31
                0
                • M mrjj
                  28 May 2018, 08:51

                  @SilverSurfer
                  Ok. so most likely they
                  are just using openCV and send as BGR888

                  So i dont see any way to convert to supported format without copy.

                  W Offline
                  W Offline
                  wrosecrans
                  wrote on 29 May 2018, 01:31 last edited by
                  #24

                  @mrjj If you use a shader in a QOpenGLWidget, you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer, which would avoid an extra copy step to normalize the channel order.

                  S 1 Reply Last reply 29 May 2018, 10:09
                  1
                  • W wrosecrans
                    29 May 2018, 01:31

                    @mrjj If you use a shader in a QOpenGLWidget, you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer, which would avoid an extra copy step to normalize the channel order.

                    S Offline
                    S Offline
                    SilverSurfer
                    wrote on 29 May 2018, 10:09 last edited by SilverSurfer
                    #25

                    @wrosecrans said in QWidget Flickering for frame by frame streaming of video:

                    you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer

                    Could you provide sample code for the same ?

                    W 1 Reply Last reply 29 May 2018, 18:03
                    0
                    • S SilverSurfer
                      29 May 2018, 10:09

                      @wrosecrans said in QWidget Flickering for frame by frame streaming of video:

                      you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer

                      Could you provide sample code for the same ?

                      W Offline
                      W Offline
                      wrosecrans
                      wrote on 29 May 2018, 18:03 last edited by
                      #26

                      @SilverSurfer I don't have the time handy to do a full working example, but this is the technique in glsl:
                      https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling

                      (The vec4 can hold "rgba" values if that's what you put in it - the example there just calls it "xyzw" because the data type generically handles any 4 floats.)

                      Basically, start from an example that draws an image with a simple glsl shader as a texture. Then hack on the shader until it flips around the colors like you want when it draws the texture. Then use your code that gets the image over the network to upload the image as the OpenGL texture every frame.

                      1 Reply Last reply
                      2

                      26/26

                      29 May 2018, 18:03

                      • Login

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