Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QVideoFrame::map() is false in android



  • Me again
    I try to capture frame from camera using QCamera and QAbstractVideoSurface. Trying convert QVideoFrame to QImage in present() function but map() return fail when run on android 9, API 28

    This working find on linux

    PixelFormat had test: Format_RGB32,Format_RGB565,Format_Jpeg

    any i idead how to convert QVideoFrame to QImage on android ? Or other way to grap camera frame


  • Lifetime Qt Champion

    Hi,

    How are you mapping your video frame ?

    Note that on Android, IIRC; you get an OpenGL texture.



  • here how i convert QVideoFrame to QImage to display

    bool AndroidFrame::present(const QVideoFrame &currentFrame)
    {
        qDebug()<<currentFrame.pixelFormat()<<currentFrame.isValid()<<endl;
        if (currentFrame.isValid()) {
            cloneFrame = currentFrame;
            qDebug()<<cloneFrame.map(QAbstractVideoBuffer::ReadWrite);
            const QImage img(cloneFrame.bits(),
                         cloneFrame.width(),
                         cloneFrame.height(),
                         QVideoFrame::imageFormatFromPixelFormat(QVideoFrame::Format_Jpeg));
    
             emit frameChanged(img);
            return true;
        }
        return false;
    }
    

    seem incorrect for android, do you have any suggestion ?


  • Lifetime Qt Champion

    Why are you mapping the frame in ReadWrite mode ? Read should be enough for your usage.


Log in to reply