In the below code the frameheight is 10000 and the width is 3000. This image is generated in half second therefore i need to process and convert this much of data display in my Qt gui graphics view.
const uint32_t* rawPixels = reinterpret_cast<const uint32_t*>(images);
for (int y = 0; y < frameHeight; y++) {
for (int x = 0; x < width; x++) {
int bufIndex = (y * width + x) + (recv_frames * width * frameHeight);
ushort pixelValue = rawPixels[bufIndex];
int scaledValue = pixelValue >> 24;
image.setPixelColor(x, currentLine + y, QColor(scaledValue, scaledValue, scaledValue));
}
}
QPixmap pixmap = QPixmap::fromImage(image);
QRectF updateRect(0, 0, 3072, frameHeight);
scene->invalidate(updateRect, QGraphicsScene::ForegroundLayer);
QGraphicsPixmapItem *pixmapItem = scene->addPixmap(pixmap.copy(0, 0, 3072, frameHeight));
pixmapItem->setPos(0, 0);
ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
As this is a really fast operation so any optimization will help. Just so you know this process is am doing in a separate thread.
Also my raw data values are not properly spread. How can you use Histogram Equalization or any sort of method to get a good contrast? (without affecting performance)
Also can I use GPU or any other hardware in Qt to make this go any faster?
I tried to do this as division is slower than shift but most of my pixel value is in 2000 very rare are in 4000 and no or negligible in 65535. If i sift this much then i get no exposure if i shift little then scaledValue goes out of range.
int scaledValue = pixelValue >> 24;
Follow-up question- As my image is to big to display in the actual size that the reason I used keepAspectRatio but the resolution isn’t good can you suggest a better approach?