Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImage unable to open jpg files
Qt 6.12 LTS is out! See what's new in the release blog

QImage unable to open jpg files

Scheduled Pinned Locked Moved General and Desktop
20 Posts 3 Posters 11.1k Views 3 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,

    How did you install Qt ?

    What does qDebug() << QImageReader::supportedImageFormats() return ?

    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
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #3

      Hi,

      I have built Qt from sources on Jetson TK1 where I have Ubuntu 14.04 LTS.
      As I wrote the problem is not for all the jpg files.
      In particular i have jpg files that I saved from 2 different webcams (Logitech C270 and C920-C) both using a Qt program and from Gnome Cheese.
      I have problem to open the two files saved with Qt.

      This is what qDebug returns:
      ("bmp", "cur", "dds", "gif", "icns", "ico", "jp2", "jpeg", "jpg", "mng", "pbm", "pgm", "png", "ppm", "svg", "svgz", "tga", "tif", "tiff", "wbmp", "webp", "xbm", "xpm")

      Regards.

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

        So, do you mean that saving a jpeg with Qt will no open with Qt again ?

        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
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #5

          Yes, it looks so.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mchinand
            wrote on last edited by
            #6

            Do you view the images from the webcams in your Qt application before saving it with Qt (QImage::save())?

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

              I think to have found the reason.
              At the beginning I included only QImage together with Opencv and I can open the jpeg files, saved by Qt, using cv::imread.
              Later I added QCamera library in the same project and I got some messages like:

              JPEG parameter struct mismatch: library thinks size is 432, caller expect 488.

              But if use QImage alone I can work without problems.
              Then I tried to save the picture in PNG format and I can open without problem with Qt.
              So, my idea is that there is some kind of conflict about JPEG format.

              Regards.

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

                You might be using two different versions of the jpeg library. The one used by OpenCV and the one for the jpeg plugin in Qt.

                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
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #9

                  @mchinand Yes, I can see the images from webcam. I use to shows in a widget with the class QViewfinder.
                  To save file I use the functions provide by QCameraImageCapture.
                  Moreover I show the captured frame in a QLabel widget by QPixmap and from this I saved with QFile.
                  But the same problem.
                  If I save in PNG or TIFF no problem.

                  @SGaist I think you are right, but I don't know how to say to Qt to use the same of OpenCV.
                  I could use OpenCV to capture the image from webcam, the problem is that OpenCV let me to do with a fix resolution. So, to try to overcome a problem I face another one.

                  Regards

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

                    Did you build either for them ?

                    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
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #11

                      @SGaist
                      OpenCV was already built in the software pack supplied with Jetson Tk1.
                      The version is made in order to get the best performance from the Jetson board.
                      Later I built Qt and Qt Creator.
                      I follow the instructions I found in Qt wiki and I added the suggested library (Building from git).
                      But I have not so deep knowledge to understand if there was something connected with jpeg library.

                      Regards.

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

                        Check with ldd where the libjpeg used by OpenCV is located. If it's the system lib then you can add -system-libjpeg to your configure options.

                        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
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          You might also want to check with Qt 5.5.1 there was a bug in 5.5.0 see this bug report

                          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
                          • ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #14

                            @SGaist Thank you for your advices.
                            I am workig on them. I will inform you as soon as I have some results.

                            1 Reply Last reply
                            0
                            • ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #15

                              @SGaist
                              I am back again.
                              Before to build with the new 5.5.1 I reset the Jetson TK1 with the new release of Jetson Pack (Before I had 1.1 now 1.2).
                              I download from Qt git the version 5.5.1 and I compiled without problem.
                              Then I download from git the version 3.6 of QtCreator and compiled wtihout problem (to compile correctly I had to modify something in 3rd party Botan as I found in nVidia forum).
                              When I run Qt Creator I have a problem in the configuration of Buil & Run.
                              I can configure the GCC Compiler but in the Kit the Compiler doesn't show any option.

                              MZ

                              1 Reply Last reply
                              0
                              • ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by
                                #16

                                @SGaist

                                About QtCreator: I can use the version that I get form Ubutnu repository (3.0.1) and I can configure the Kit without problem.

                                About jpeg: I still have problem. Now I cannot read the image from webcam.

                                MZ

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

                                  Are you sure you are building using the system libjpeg ?

                                  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
                                  • ? Offline
                                    ? Offline
                                    A Former User
                                    wrote on last edited by
                                    #18

                                    With the version 5.5.0 the option didin't work. There was an error.
                                    Now I try again with 5.5.1 and I have an error again.
                                    Here the steps i did:

                                    • download source from git;
                                    • init-repository ( I use the option --no-webkit but it looks it doesn't work because I get also webkit);
                                    • checkout 5.5.1;
                                    • removed manually webkits/webengine (deleted forlders);
                                    • ./configure -qtxcb -system-libjpeg -nomake examples -nomake tests;
                                    • make: with -system-libjpeg I have an error
                                      ../../../gui/image/qjpeghandler.cpp:64:21: fatal error: jpeglib.h: No such file or directory

                                    MZ

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

                                      Did you install the system libjpeg dev package ?

                                      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
                                      • ? Offline
                                        ? Offline
                                        A Former User
                                        wrote on last edited by
                                        #20

                                        You are right, I forgot to install it.
                                        I did and rebuild.
                                        But still the same error:
                                        JPEG parameter struct mismatch: library thinks size is 432, caller expect 488.

                                        In the past I looked for examples of use of Qt + OpenCV and if possible developed on Jetson TK1.
                                        I found some example of Qt + OpenCV and one project developed on Jetson TK1 with only OpenCV.
                                        All don't use Qt (QCamera) to grab pictures (while they use all the other features of Qt, even QThread) but directly OpenCV.
                                        The one developed with Jetson TK1 has developed a tool based directly on V4L2, to have more flexibility in the control of the camera.
                                        These examples work.

                                        MZ

                                        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
                                        • Unsolved