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. Trying to capture QImage of video frame
Forum Updated to NodeBB v4.3 + New Features

Trying to capture QImage of video frame

Scheduled Pinned Locked Moved Unsolved General and Desktop
30 Posts 5 Posters 17.7k 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.
  • A Offline
    A Offline
    Anjani
    wrote on last edited by Anjani
    #16

    no sir not really. The basic code is same as posted in this thread previously. This is just for the reference.You can directly suggest me which api or function will change the pixel formate of frame to RGB and allow me to save direct RGB only? or manually I need to add logic for conversion?
    and the other thing I am not getting is why this gives me same frame? or I would say 1st frame only...

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

      It depends on the output you'll be using e.g. if OpenGL a shader will be used for that conversion.

      Note that your grabber looks strange, you return all the types rather than just the one you would like to have and then you map the video frame as write only but you only read from it.

      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
      0
      • A Offline
        A Offline
        Anjani
        wrote on last edited by
        #18

        Thank you for reply. I tried as you say. but didn't get any change in output.what I do now?
        k if you can suggest me any thing which can change frame output(regardless of its formate) rather than being same all the time at any instance i capture a frame.Output is going to same and it is equal to first frame. for instance at least if i'll get different pictures for different frames than for formate i'll convert manually,just for now.

        1 Reply Last reply
        0
        • benlauB Offline
          benlauB Offline
          benlau
          Qt Champions 2016
          wrote on last edited by
          #19

          For converting YUV to RGB, Qt has a private API , qt_imageFromVideoFrame() , which could convert QVideoFrame to QImage in RGB format (I can't remember the exact RGB format to be converted) .

          p.s It can't handle texture frame

          You could try and see could it solve your problem first.

          To enable the private API, you have to add this line in your .pro file

          QT += multimedia-private
          

          And include this header file

          #include "private/qvideoframe_p.h"
          

          Remarks: That is a private API. Use it as your own risk

          1 Reply Last reply
          2
          • A Offline
            A Offline
            Anjani
            wrote on last edited by
            #20

            thank you for reply.I tried it but not working. I tried it after my clone frame syntax(in framegrabber.cpp file function present). Is that write position? I am new to Qt. I dont have much idea about it.

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

              Please be more precise. "Not working" doesn't say much. What are you getting ? A blank image ? A black image ? Funny colours ?

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

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                Please be more precise. "Not working" doesn't say much. What are you getting ? A blank image ? A black image ? Funny colours ?

                A Offline
                A Offline
                Anjani
                wrote on last edited by
                #22

                @SGaist
                ooh sorry for that. it still gives me .jpg image, where I want RGB data of image/frame.yet I am getting only the first frame all though I try to capture frame at any time.

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

                  Aren't you getting a .png 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
                  0
                  • A Offline
                    A Offline
                    Anjani
                    wrote on last edited by
                    #24

                    yes i am getting .png but i want data in rgb format. because raw data format is only allowed on my frame buffer to display.

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

                      You do realise that if you load your image again in a QImage, you'll get a RGB image ?

                      If you really want to save an RGB image then go for bitmap but beware, it's uncompressed.

                      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
                      0
                      • A Offline
                        A Offline
                        Anjani
                        wrote on last edited by
                        #26

                        oh yes thank you. this will solve my problem partially. but what about new frame capture.? can you please help me out where I am lacking or what i am missing? why I am getting the same frame every time?If I'll get updated frame my task will be almost on final stage.please solve this.and again thank you.

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

                          You always take the same image from the list, check that your counter increments properly and that you indeed update the list.

                          On a side note, you should pass const reference to QImage parameters. That will save useless copies.

                          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
                          0
                          • A Offline
                            A Offline
                            Anjani
                            wrote on last edited by
                            #28

                            Thank you for reply and sorry for late response. Yes probably i am incrementing the counter properly. and sir I couldn't understand what you said about const reference to QImage parameter?

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

                              Use: const QImage &image as parameter

                              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
                              0
                              • A Offline
                                A Offline
                                Anjani
                                wrote on last edited by
                                #30

                                K let me try it

                                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