So some background information about my problem. I have a program which displays images coming from webcam. The program works just fine, but the frame rate never reaches anywhere near the 30 which is coming from the camera. I have pinpointed the issue and it is with converting QVideoFrame to QImage and then drawing the image. On windows this code works fine and the whole drawing process takes about 2ms. On linux it's completely different story, drawing the QImage takes more than 20ms which may not sound like much but when it's added for every frame the framerate drops to half of what it should be.
Now i know drawing QImages is slow on linux environments from doing some research but i have no clue how to convert the QVideoFrame straight to QPixmap which is faster to draw. Using QPixmap::fromImage() is not viable solution because that is slow as well.
Current implementation for drawing the image coming from the webcam.
if(mVFcurrentFrame.map(QAbstractVideoBuffer::ReadOnly))
{
QImage image
(mVFcurrentFrame.
bits(), mVFcurrentFrame.
width(), mVFcurrentFrame.
height(), mVFcurrentFrame.
bytesPerLine(), imageFormat
);
painter->drawImage(0,0,image); //Takes about 20ms
mVFcurrentFrame.unmap();
}
if(mVFcurrentFrame.map(QAbstractVideoBuffer::ReadOnly))
{
QImage image(mVFcurrentFrame.bits(), mVFcurrentFrame.width(), mVFcurrentFrame.height(), mVFcurrentFrame.bytesPerLine(), imageFormat);
painter->drawImage(0,0,image); //Takes about 20ms
mVFcurrentFrame.unmap();
}
To copy to clipboard, switch view to plain text mode
So my questions are:
Is it possible to convert QVideoFrame straight to QPixmap and would it be a viable solution?
Is there some other way i could speed up the drawing process?
Bookmarks