ImageCapture QML Type

捕捉相机图像的接口。更多

Import Statement: import QtMultimedia

属性

信号

方法

详细说明

该类型允许您捕捉静态图像,并在图像可用或保存到磁盘时收到通知。

Item {
    width: 640
    height: 360

    CaptureSession {
        imageCapture : ImageCapture {
            id: imageCapture
        }
        camera: Camera {
            id: camera
        }

        videoOutput: videoOutput
    }
    VideoOutput {
        id: videoOutput
        anchors.fill: parent

        MouseArea {
            anchors.fill: parent;
            onClicked: imageCapture.capture();
        }
    }

    Image {
        id: photoPreview
        source: imageCapture.preview // always shows the last captured image
    }
}

属性文档

preview : string [read-only]

该属性包含最新捕获图像的 URL。它可以连接到Image 元素的源属性,以显示最后捕获的图像。

CaptureSession {
    camera: Camera {}
    imageCapture: ImageCapture {
        id: capture
    }
}
Image {
    source: capture.preview
}

另请参阅 saveToFile


readyForCapture : bool [read-only]

该属性包含一个 bool 值,表示摄像机是否已准备好捕捉照片。

readyfalse 时调用capture() 或captureToFile() 是不允许的,会导致错误。


信号文档

errorOccurred(id, error, errorString)

id error 是一个 ImageCapture::Error 类型的枚举。描述性信息见 。errorString

注: 相应的处理程序是onErrorOccurred


imageCaptured(requestId, preview)

当捕获到 ID 为requestId 的图像但尚未保存到文件系统时,将发出此信号。preview 参数为捕获的图像。

注: 相应的处理程序是onImageCaptured

另请参阅 imageSavedpreview


imageMetadataAvailable(id, metaData)

当请求id 的图像有新的metaData 时,会发出此信号。

注: 相应的处理程序是onImageMetadataAvailable

另请参见 imageCaptured


imageSaved(id, fileName)

请求id 的图像写入文件系统后,会发出此信号。fileName 是本地文件路径,而不是 URL。

注意: 相应的处理程序是onImageSaved

另请参阅 imageCaptured


方法文档

capture()

开始图像捕捉。捕获完成后,将发出imageCapturedimageSaved 信号。

捕获的图像将通过预览属性提供,可用作 QML 图像项的源。然后可使用saveToFile() 方法保存图像。

相机会保存所有捕捉参数,如曝光设置或图像处理参数,因此调用 capture() 后更改相机参数不会影响之前的捕捉请求。

capture()返回捕捉请求 ID 参数,与 imageExposed()、imageCaptured( )、imageMetadataAvailable() 和imageSaved() 信号一起使用。

另请参阅 readyForCapturepreview


captureToFile(location)

功能与capture() 相同,但会自动将捕获的图像保存到指定的location

另请参阅 capture


saveToFile(location)

将最后捕获的图像保存到location

另请参阅 capturepreview


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.