ImageCapture QML Type
捕捉相机图像的接口。更多
Import Statement: | import QtMultimedia |
属性
- preview : string
- readyForCapture : bool
信号
- errorOccurred(id, error, errorString)
- imageCaptured(requestId, preview)
- imageMetadataAvailable(id, metaData)
- imageSaved(id, fileName)
方法
- capture()
- captureToFile(location)
- saveToFile(location)
详细说明
该类型允许您捕捉静态图像,并在图像可用或保存到磁盘时收到通知。
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 |
该属性包含最新捕获图像的 URL。它可以连接到Image 元素的源属性,以显示最后捕获的图像。
CaptureSession { camera: Camera {} imageCapture: ImageCapture { id: capture } } Image { source: capture.preview }
另请参阅 saveToFile 。
readyForCapture : bool |
该属性包含一个 bool 值,表示摄像机是否已准备好捕捉照片。
在ready为false
时调用capture() 或captureToFile() 是不允许的,会导致错误。
信号文档
errorOccurred(id, error, errorString) |
id error 是一个 ImageCapture::Error 类型的枚举。描述性信息见 。errorString
注: 相应的处理程序是onErrorOccurred
。
imageCaptured(requestId, preview) |
当捕获到 ID 为requestId 的图像但尚未保存到文件系统时,将发出此信号。preview 参数为捕获的图像。
注: 相应的处理程序是onImageCaptured
。
另请参阅 imageSaved 和preview 。
imageMetadataAvailable(id, metaData) |
imageSaved(id, fileName) |
方法文档
capture() |
开始图像捕捉。捕获完成后,将发出imageCaptured 和imageSaved 信号。
捕获的图像将通过预览属性提供,可用作 QML 图像项的源。然后可使用saveToFile() 方法保存图像。
相机会保存所有捕捉参数,如曝光设置或图像处理参数,因此调用 capture() 后更改相机参数不会影响之前的捕捉请求。
capture()返回捕捉请求 ID 参数,与 imageExposed()、imageCaptured( )、imageMetadataAvailable() 和imageSaved() 信号一起使用。
另请参阅 readyForCapture 和preview 。
© 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.