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. QPixmap or QImage for JFIF image format
Forum Updated to NodeBB v4.3 + New Features

QPixmap or QImage for JFIF image format

Scheduled Pinned Locked Moved Solved General and Desktop
qpixmapqimagejpegjfif
8 Posts 2 Posters 3.6k Views 1 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
    scottnat
    wrote on 30 Dec 2017, 15:28 last edited by
    #1

    Hi all, I have some incoming image data from a camera that is in JFIF APP0 format.
    The first four bytes are: 0xFF, 0xD8, 0xFF, 0xE9.

    Which what I see from https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format (JFIF APP0 marker segment).

    Problem: Looking through the docs, I am unable to find anything that supports JFIF. As the header formats are different than JPEG, I was wondering if anyone has any recommendations on a workaround with either using QPixmap or QImage?

    Alternative: I could also retrieve image data as raw matrix (mat) form and use OpenCV methods, however i was unable to build opencv for my QT 5.1, MSVC2015 64 bit.

    Goal 1: Display image on QLabel or QGraphicsView.
    Goal 2: Video from sequence of images.

    Thanks and hoping to hear from you.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 30 Dec 2017, 22:37 last edited by
      #2

      Hi,

      Did you try to force the use of the JPEG plugin to read the image ?
      Can you provide a sample image in that format ?

      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 31 Dec 2017, 07:24
      0
      • S SGaist
        30 Dec 2017, 22:37

        Hi,

        Did you try to force the use of the JPEG plugin to read the image ?
        Can you provide a sample image in that format ?

        S Offline
        S Offline
        scottnat
        wrote on 31 Dec 2017, 07:24 last edited by
        #3

        @SGaist Hi yes, I was able to force the JFIF format and found a solution to display my image on a QLabel.

        I was wondering now, how would I be able to play a sequence of images onto the QLabel, like an animation/video.

            for(int x=0;x<10;x++){ //GET 10 IMAGES INTO QList<QPixmap>
                
                BYTE* cameraImage = new BYTE[dwMaxImageBytes];
                DWORD dwImageBytes;
                CaptureImage(cameraImage, dwMaxImageBytes, &dwImageBytes); //API for getting JFIF image
                
                QPixmap pix;
                pix.loadFromData((const uchar*)cameraImage,dwImageBytes,"JFIF");
                *qpixmaplist << pix; //declared in header file as QList<QPixmap>* qpixmaplist
            }
        
            timer.setInterval(1000); //attempting to display one image on a QLabel every 1 sec
            connect(&timer,SIGNAL(timeout()),this,SLOT(procPixmap()));
            timer.start();
        

        The procPixmap slot:

        void MainWindow::procPixmap(){
            if(pixcounter>=10){
                timer.stop();
                disconnect(&timer,SIGNAL(timeout()),this,SLOT(procPixmap()));
            }
            else{
                ui->label->setPixmap(qpixmaplist->at(pixcounter));
                pixcounter++;
            }
        }
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 31 Dec 2017, 20:57 last edited by
          #4

          Something is not clear, do you want to get the images from the camera or from files to show that "video" ?

          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 2 Jan 2018, 02:37
          0
          • S SGaist
            31 Dec 2017, 20:57

            Something is not clear, do you want to get the images from the camera or from files to show that "video" ?

            S Offline
            S Offline
            scottnat
            wrote on 2 Jan 2018, 02:37 last edited by
            #5

            @SGaist
            Thanks for the reply. Basically, from a camera's API "CaptureImage", i store one image in an array of unsigned char bytes.

            CaptureImage(cameraImage, dwMaxImageBytes, &dwImageBytes); 
            

            That one image is loaded as a QPixmap, and fed to a QList of QPixmaps.

            QPixmap pix;
            pix.loadFromData((const uchar*)cameraImage,dwImageBytes,"JFIF");
            qpixmaplist << pix; 
            

            Now, everything works. My images are displayed at a rate determined by the timer interval.

            However, is there a cleaner way to convert these QList <QPixmap> into a more video format, rather than having to physically update images, like a script boy on a TV set.
            ui->label->setPixmap(qpixmaplist[counter]); counter++;

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 2 Jan 2018, 07:43 last edited by
              #6

              How fast are these images coming ?

              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 2 Jan 2018, 12:50
              0
              • S SGaist
                2 Jan 2018, 07:43

                How fast are these images coming ?

                S Offline
                S Offline
                scottnat
                wrote on 2 Jan 2018, 12:50 last edited by
                #7

                @SGaist
                Thanks for the reply. For me:

                • Each call to the CaptureImage API takes approximate 6 ms.
                • Loading to the QList<QPixmap> takes an additional 90 ms.
                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 2 Jan 2018, 21:32 last edited by
                  #8

                  Why create a QList and not do the conversion directly after calling CaptureImage ?

                  Otherwise, does the library you are using to get the image provide a streaming API ?

                  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

                  2/8

                  30 Dec 2017, 22:37

                  topic:navigator.unread, 6
                  • Login

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