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. After convertion QVideoFrame to QImage, the QImage is zoomed and streched
Forum Updated to NodeBB v4.3 + New Features

After convertion QVideoFrame to QImage, the QImage is zoomed and streched

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
24 Posts 5 Posters 3.8k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 8 Oct 2020, 18:27 last edited by
    #11

    Hi,

    To add to @GrecKo, YUYV is not directly mappable to an indexed image format.

    What exactly are you trying to achieve ?

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

    F M 2 Replies Last reply 8 Oct 2020, 19:29
    0
    • S SGaist
      8 Oct 2020, 18:27

      Hi,

      To add to @GrecKo, YUYV is not directly mappable to an indexed image format.

      What exactly are you trying to achieve ?

      F Offline
      F Offline
      fcarney
      wrote on 8 Oct 2020, 19:29 last edited by
      #12

      @SGaist This talks about converting YUV to RGB. Is this the same as UYUV?

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 8 Oct 2020, 20:13 last edited by
        #13

        YUV is a color space as is RGB, YUYV is one of the many possible ways to store YUV data like you have RGB, BGR, etc.

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

        M 1 Reply Last reply 9 Oct 2020, 07:11
        0
        • S SGaist
          8 Oct 2020, 18:27

          Hi,

          To add to @GrecKo, YUYV is not directly mappable to an indexed image format.

          What exactly are you trying to achieve ?

          M Offline
          M Offline
          Melle_87
          wrote on 9 Oct 2020, 06:13 last edited by
          #14

          @SGaist: I want to detect barcodes. Therefore I use ZBar and QZXing.
          For both I need a data of a QImage. That is the reason why I have to convert the QVideoFrame to QImage.

          G 1 Reply Last reply 9 Oct 2020, 08:04
          0
          • S SGaist
            8 Oct 2020, 20:13

            YUV is a color space as is RGB, YUYV is one of the many possible ways to store YUV data like you have RGB, BGR, etc.

            M Offline
            M Offline
            Melle_87
            wrote on 9 Oct 2020, 07:11 last edited by
            #15

            @SGaist: But what could be the explanation that everything was fine on Raspberry Pi 3 with Raspbian Stretch and now I have problems on Raspberry Pi 4 with Raspbian Buster?

            G 1 Reply Last reply 9 Oct 2020, 08:01
            0
            • M Melle_87
              9 Oct 2020, 07:11

              @SGaist: But what could be the explanation that everything was fine on Raspberry Pi 3 with Raspbian Stretch and now I have problems on Raspberry Pi 4 with Raspbian Buster?

              G Offline
              G Offline
              GrecKo
              Qt Champions 2018
              wrote on 9 Oct 2020, 08:01 last edited by
              #16

              @Melle_87 said in After convertion QVideoFrame to QImage, the QImage is zoomed and streched:

              @SGaist: But what could be the explanation that everything was fine on Raspberry Pi 3 with Raspbian Stretch and now I have problems on Raspberry Pi 4 with Raspbian Buster?

              My guess is that the Pi 3 was providing frames in a different format.

              1 Reply Last reply
              0
              • M Melle_87
                9 Oct 2020, 06:13

                @SGaist: I want to detect barcodes. Therefore I use ZBar and QZXing.
                For both I need a data of a QImage. That is the reason why I have to convert the QVideoFrame to QImage.

                G Offline
                G Offline
                GrecKo
                Qt Champions 2018
                wrote on 9 Oct 2020, 08:04 last edited by GrecKo 10 Sept 2020, 08:04
                #17

                @Melle_87 said in After convertion QVideoFrame to QImage, the QImage is zoomed and streched:

                @SGaist: I want to detect barcodes. Therefore I use ZBar and QZXing.
                For both I need a data of a QImage. That is the reason why I have to convert the QVideoFrame to QImage.

                QZXing is supposed to handle YUYV fine in its video filters : https://github.com/ftylitak/qzxing/blob/master/src/QZXingFilter.cpp#L325

                M 1 Reply Last reply 12 Oct 2020, 11:44
                3
                • G GrecKo
                  9 Oct 2020, 08:04

                  @Melle_87 said in After convertion QVideoFrame to QImage, the QImage is zoomed and streched:

                  @SGaist: I want to detect barcodes. Therefore I use ZBar and QZXing.
                  For both I need a data of a QImage. That is the reason why I have to convert the QVideoFrame to QImage.

                  QZXing is supposed to handle YUYV fine in its video filters : https://github.com/ftylitak/qzxing/blob/master/src/QZXingFilter.cpp#L325

                  M Offline
                  M Offline
                  Melle_87
                  wrote on 12 Oct 2020, 11:44 last edited by
                  #18

                  @GrecKo: Thank for the link. I tried to register QZXingFilter in main.cpp:

                  qmlRegisterType<QZXingFilter>("MY.QZXingFilter", 1, 0, "MyQZXingFilter");
                  

                  Then I importet it in my qml file, instatiated it and assigned to my VideoOutput:

                  import MY.QZXingFilter 1.0
                  
                  MyQZXingFilter {
                      id: myBarcodeFilter
                  }
                  
                  My_Camera {
                      id: camera
                  }
                     
                  VideoOutput {
                      id: vid
                      source: camera
                      filters: [ myBarcodeFilter ]   
                  }
                  

                  But now I get some errors.

                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `int qmlRegisterType<QZXingFilter>(char const*, int, int, char const*)':
                  /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtQml/qqml.h:311: undefined reference to `QZXingFilter::staticMetaObject'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QQmlPrivate::QQmlElement<QZXingFilter>::QQmlElement()':
                  /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtQml/qqmlprivate.h:103: undefined reference to `QZXingFilter::QZXingFilter(QObject*)'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QtPrivate::MetaObjectForType<QZXingFilter*, void>::value()':
                  /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtCore/qmetatype.h:1476: undefined reference to `QZXingFilter::staticMetaObject'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QMetaTypeIdQObject<QZXingFilter*, 8>::qt_metatype_id()':
                  /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtCore/qmetatype.h:1841: undefined reference to `QZXingFilter::staticMetaObject'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x8): undefined reference to `QZXingFilter::metaObject() const'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0xc): undefined reference to `QZXingFilter::qt_metacast(char const*)'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x10): undefined reference to `QZXingFilter::qt_metacall(QMetaObject::Call, int, void**)'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x38): undefined reference to `QZXingFilter::createFilterRunnable()'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTIN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTIN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x8): undefined reference to `typeinfo for QZXingFilter'
                  /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QQmlPrivate::QQmlElement<QZXingFilter>::~QQmlElement()':
                  /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtQml/qqmlprivate.h:108: undefined reference to `QZXingFilter::~QZXingFilter()'
                  

                  Do you know what I am doing wrong?

                  J 1 Reply Last reply 12 Oct 2020, 11:59
                  0
                  • M Melle_87
                    12 Oct 2020, 11:44

                    @GrecKo: Thank for the link. I tried to register QZXingFilter in main.cpp:

                    qmlRegisterType<QZXingFilter>("MY.QZXingFilter", 1, 0, "MyQZXingFilter");
                    

                    Then I importet it in my qml file, instatiated it and assigned to my VideoOutput:

                    import MY.QZXingFilter 1.0
                    
                    MyQZXingFilter {
                        id: myBarcodeFilter
                    }
                    
                    My_Camera {
                        id: camera
                    }
                       
                    VideoOutput {
                        id: vid
                        source: camera
                        filters: [ myBarcodeFilter ]   
                    }
                    

                    But now I get some errors.

                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `int qmlRegisterType<QZXingFilter>(char const*, int, int, char const*)':
                    /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtQml/qqml.h:311: undefined reference to `QZXingFilter::staticMetaObject'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QQmlPrivate::QQmlElement<QZXingFilter>::QQmlElement()':
                    /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtQml/qqmlprivate.h:103: undefined reference to `QZXingFilter::QZXingFilter(QObject*)'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QtPrivate::MetaObjectForType<QZXingFilter*, void>::value()':
                    /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtCore/qmetatype.h:1476: undefined reference to `QZXingFilter::staticMetaObject'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QMetaTypeIdQObject<QZXingFilter*, 8>::qt_metatype_id()':
                    /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtCore/qmetatype.h:1841: undefined reference to `QZXingFilter::staticMetaObject'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x8): undefined reference to `QZXingFilter::metaObject() const'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0xc): undefined reference to `QZXingFilter::qt_metacast(char const*)'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x10): undefined reference to `QZXingFilter::qt_metacall(QMetaObject::Call, int, void**)'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTVN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x38): undefined reference to `QZXingFilter::createFilterRunnable()'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o:(.data.rel.ro._ZTIN11QQmlPrivate11QQmlElementI12QZXingFilterEE[_ZTIN11QQmlPrivate11QQmlElementI12QZXingFilterEE]+0x8): undefined reference to `typeinfo for QZXingFilter'
                    /opt/raspi-tools-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.o: in function `QQmlPrivate::QQmlElement<QZXingFilter>::~QQmlElement()':
                    /home/m/Builds/build_PY-Raspi_Buster-Debug/../../../x/workspace/gateway-setup/qt-for-raspi4-root-buster-pi3-vc4-tc5/qt5pi/include/QtQml/qqmlprivate.h:108: undefined reference to `QZXingFilter::~QZXingFilter()'
                    

                    Do you know what I am doing wrong?

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 12 Oct 2020, 11:59 last edited by
                    #19

                    @Melle_87 said in After convertion QVideoFrame to QImage, the QImage is zoomed and streched:

                    MyQZXingFilter

                    Is it derived from QObject?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    M 1 Reply Last reply 12 Oct 2020, 12:11
                    0
                    • J jsulm
                      12 Oct 2020, 11:59

                      @Melle_87 said in After convertion QVideoFrame to QImage, the QImage is zoomed and streched:

                      MyQZXingFilter

                      Is it derived from QObject?

                      M Offline
                      M Offline
                      Melle_87
                      wrote on 12 Oct 2020, 12:11 last edited by
                      #20

                      @jsulm: It is derived from QAbstractVideoFilter.

                      J 1 Reply Last reply 12 Oct 2020, 12:19
                      0
                      • M Melle_87
                        12 Oct 2020, 12:11

                        @jsulm: It is derived from QAbstractVideoFilter.

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 12 Oct 2020, 12:19 last edited by jsulm 10 Dec 2020, 12:20
                        #21

                        @Melle_87 Then I guess you do not build/link moc_*.cpp file for MyQZXingFilter

                        undefined reference to `QZXingFilter::QZXingFilter(QObject*)' - actually you seem to not link QZXingFilter at all

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          GrecKo
                          Qt Champions 2018
                          wrote on 12 Oct 2020, 12:24 last edited by
                          #22

                          How did you add QZXing to your project?
                          https://github.com/ftylitak/qzxing#howToInclude has instructions on how to do it

                          M 1 Reply Last reply 12 Oct 2020, 13:04
                          1
                          • G GrecKo
                            12 Oct 2020, 12:24

                            How did you add QZXing to your project?
                            https://github.com/ftylitak/qzxing#howToInclude has instructions on how to do it

                            M Offline
                            M Offline
                            Melle_87
                            wrote on 12 Oct 2020, 13:04 last edited by
                            #23

                            @GrecKo: Okay. Now I am able to use the QZXingFilter in VideoOutput.
                            But the conversion from QVideoFrame to QImage is not successful.
                            QZXingFilter says:

                            QZXingFilterRunnable error: Cant create image file to process.
                            Maybe it was a format conversion problem? 
                            VideoFrame format:  Format_YUYV
                            Image corresponding format:  QImage::Format_Invalid
                            

                            What should I do now???

                            M 1 Reply Last reply 12 Oct 2020, 13:19
                            0
                            • M Melle_87
                              12 Oct 2020, 13:04

                              @GrecKo: Okay. Now I am able to use the QZXingFilter in VideoOutput.
                              But the conversion from QVideoFrame to QImage is not successful.
                              QZXingFilter says:

                              QZXingFilterRunnable error: Cant create image file to process.
                              Maybe it was a format conversion problem? 
                              VideoFrame format:  Format_YUYV
                              Image corresponding format:  QImage::Format_Invalid
                              

                              What should I do now???

                              M Offline
                              M Offline
                              Melle_87
                              wrote on 12 Oct 2020, 13:19 last edited by
                              #24

                              It was my fault. I pulled the latest version of QZXing. Now the conversion from QVideoFrame to QImage is working.

                              1 Reply Last reply
                              0

                              20/24

                              12 Oct 2020, 12:11

                              • Login

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