How to render large Raw 16bit image in Graphics view in Qt C++ every second

The below code consist of 3 parts (threads in this case).
In part 1: U have a hardware which act as a camera and generates the RAW data of each really fast roughly 3000*5000 pixel. Each pixel is Raw value of 16bit in grayscale please don’t be concern for how this camera works just assume it generates the data.

(Thread1)
void camera(){
    char* framebuf = NULL;
    uint8_t* images = NULL;
    images = new  uint8_t[3000*5000*100];
    framebuf = new char[3000*5000];
    for(int i = 0, i<3000*5000; i++){
        framebuf+i = "1AD2"; // sudo code not actual implementation
    }
    // copy these lines to image in memory
    memcpy(images + (recv_frames * ImageByteSize), framebuf, ImageByteSize);
    // not emit the index of read and location to different thread
    emit transferCurrentFrame(images, index);
}

The camera function is called 100 times.

Part2: In this you get this emited signal in different thread which read the whole image and convert it to 8 bit value (as i am under the impression that the graphicsview can only handle 8 bit data).

(Thread2)

Display::Display(QObject *parent)
: QThread{parent}, image(3000, 5000, QImage::Format_Grayscale16)
{}

void ProcessRecievedFrame(uint8_t* images, int index){
    const uint32_t* rawPixels = reinterpret_cast<const uint32_t*>(images);
    for (int y = 0; y < 5000; y++) {
        for (int x = 0; x < 3000; x++) {
            int bufIndex = (y * width + x) + (index* width * frameHeight);
            ushort pixelValue = rawPixels[bufIndex];
            int scaledValue = static_cast<int>(static_cast<double>(pixelValue) >> 8);
            image.setPixelColor(x, currentLine + y, QColor(scaledValue, scaledValue, scaledValue));
        }
    }
    emit frameProcessed(image);
}

I am not sure whether i need to scale my 16 bit value or not or can I use them directly but this is computational heavy and causes lag in loading when dealing with so much data.

Part 3: This is the main thread which runs GUI and grphicsView. This thread takes the signal from Thread2. The pgraphics view dimension is huge and therefore I have to keep the aspectratio to fit the image.

(Thread3)
GUI::GUI(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::GUI)
{
    ui->setupUi(this);
    m_try = new Try(this);

    //initilise the graphics view
    scene = new QGraphicsScene();
    scene->setSceneRect(0, 0, 3000, 5000*100);
    scene->setBackgroundBrush(Qt::black);
    ui->graphicsView->setScene(scene);
    ui->graphicsView->rotate(270);
    ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
}    

void GUI::resetCurrentLine(const QImage &image) {

    int frameHeight = 5000;
    QPixmap pixmap = QPixmap::fromImage(image);
    QRectF updateRect(0, currentLinegui, 3000, frameHeight);
    scene->invalidate(updateRect, QGraphicsScene::ForegroundLayer);
    QGraphicsPixmapItem *pixmapItem = scene->addPixmap(pixmap.copy(0, currentLinegui, 3000,     frameHeight));
    pixmapItem->setPos(0, currentLinegui);
    currentLinegui += frameHeight;
    ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);

    if (currentLinegui > 5000){
        qDebug() << "doing reset" << "breset" << currentLinegui;
        currentLinegui = 0;
        scene->clear();
        scene->setBackgroundBrush(Qt::black);
        ui->graphicsView->setScene(scene);
        ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
    }
}

Note: After showing 5000 lines I refresh my graphicsview to black

Right now everything is working as per my expectation but only problem is the time delay. The Image isn’t shown immediately. Approx. each image is shown after 5 seconds after acquisition and this time adds up to next image. So even though the acquisition of 3 image takes 3 seconds but the last image is shown after 15 seconds.

My assumption is scaling every bit to 8bit ans using setPixelColor cause this problem as my i7 cpu usage goes to 100% let me know if I am wrong

I assume this is enough information but let me know if you still need more clarification on this problem?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật