简体   繁体   English

QML叠加在摄像机视频上

[英]QML overlay on the camera video

I am trying to draw some overlay on the frame captured by the Camera objet in Qt/QML. 我试图在Qt / QML的Camera objet捕获的帧上绘制一些叠加层。 The camera itself is defined as: 相机本身定义为:

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

Now when I call camera.videorecorder.record() , the camera starts recording and the current frame is displayed on the video output canvas. 现在,当我调用camera.videorecorder.record() ,摄像机开始记录,当前帧显示在视频输出画布上。 Now, what I would like to do is draw a rectangle at some arbitrary location on the frame. 现在,我想做的是在框架上的任意位置绘制一个矩形。

I see that there are some shader effects example ( http://doc.qt.io/qt-5/qtmultimedia-multimedia-video-qmlvideofx-example.html ) but they look really complicated for what I want to do and I am not versed with GLSL. 我看到有一些着色器效果示例( http://doc.qt.io/qt-5/qtmultimedia-multimedia-video-qmlvideofx-example.html ),但是对于我想做的事情,它们看起来确实很复杂,不精通GLSL。

Something like this? 像这样吗

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: This will work too: 编辑:这也将工作:

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM