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