首页 文章

QML叠加在摄像机视频上

提问于
浏览
0

我试图在Qt / QML中的Camera objet捕获的帧上绘制一些叠加 . 相机本身定义为:

Camera {
    id: camera
    captureMode: Camera.CaptureVideo
}
VideoOutput {
    source: camera
    focus : visible 
    anchors.fill: parent
}

现在当我拨打 camera.videorecorder.record() 时,摄像机开始录制,当前帧显示在视频输出画布上 . 现在,我想做的是在框架上的任意位置绘制一个矩形 .

我看到有一些着色器效果示例(http://doc.qt.io/qt-5/qtmultimedia-multimedia-video-qmlvideofx-example.html),但它们看起来非常复杂,我想做什么,而且我不熟悉GLSL .

1 回答

  • 3

    像这样的东西?

    Camera {
        id: camera
        captureMode: Camera.CaptureVideo
    }
    
    VideoOutput {
        source: camera
        focus : visible
        anchors.fill: parent
        Rectangle {
                color: "red";
                width: parent.width / 2;
                height: parent.height / 2;
                anchors.centerIn: parent;
       }
    }
    

    Edit: 这也可以:

    Camera {
        id: camera
        captureMode: Camera.CaptureVideo
    }
    VideoOutput {
        source: camera
        focus : visible
        anchors.fill: parent
    }
    Rectangle {
            color: "red";
            width: parent.width / 2;
            height: parent.height / 2;
            anchors.centerIn: parent;
    }
    

相关问题