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. Displaying an image based on Mono10 (Y10P) 10-bit Monochrome lsb Packed data

Displaying an image based on Mono10 (Y10P) 10-bit Monochrome lsb Packed data

Scheduled Pinned Locked Moved Unsolved General and Desktop
qimageimage display
2 Posts 2 Posters 787 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 Offline
    S Offline
    szumial
    wrote on 24 Mar 2021, 15:49 last edited by szumial
    #1

    Hi!
    I am working on an image acquisition library which collects data from a frame grabber card. Together with the attached camera it outputs uchar* data. I have implemented a somehow beginner and easy code to display the data using a QImage and a QLabel. Everyting worked well until I had to change the output data format from 8 bit Mono 8, to a 10 bit Mono 10 monochrome lsb packed data (Y10P) format. After the change, the displayed image is not properly interpreted by the QImage constructor, resulting in some mess being shown in my application's GUI. I can see the shape of the object placed in front of the camera, but the pixels are not put together correctly. Would you be able to assist me in finding a way to correct the data or hinting a better way of displaying it?

    From what I understand, the QImage class' constructor is likely not (at least ina straightforward way) compatible with the current output data structure. The memory layout has changed as follows:

    From this:
    bdf720dd-1631-4212-a429-46acfd5c5ac7-image.png

    To that:
    a97412bf-d498-457b-bcfa-1a591e98a888-image.png

    Here is the sample code on how I display the image at the moment. Note that I have connected the updateBufferData() method with a QTimer, which triggers it with a selected timeout.

    void MainWindow::updateBufferData()
    {
        int width = imageProcessingClass->getImageWidth();
        int height = imageProcessingClass->getImageHeight();
        int bufferPitch = imageProcessingClass->getBufferPitch();
    
        if(imageProcessingClass->popBufferImage() == NULL)
        {
            return;
        }
        else
        {
            createImage(imageProcessingClass->popBufferImage().get(), width, height, bufferPitch);
        }
    }
    
    void MainWindow::createImage(uchar *bufferImage, int width, int height, int bufferPitch)
    {
        myImage = new QImage;
        myImage = new QImage(bufferImage, width, height, bufferPitch, QImage::Format_Grayscale8);
        pixmap = QPixmap::fromImage(*myImage);
        ui->label->setPixmap(pixmap.scaled(width/6, height/6, Qt::KeepAspectRatio));
    }
    

    None of the formats available in the QImage class matches the current output. I am aware that the sample code is not the best way of displaying the grabbed image frames, but I am only looking for a way to quickly preview the output from my hardware. Perhaps I should be looking at an external API to display the captured data, but if possible, I'd like to avoid that.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Mar 2021, 19:43 last edited by
      #2

      Hi,

      The most "simple" is to downsample from 10 to 8 bit.

      Maybe OpenCV has better support for that kind of format and might be an alternative.

      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
      1

      2/2

      24 Mar 2021, 19:43

      • Login

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