And*_*rra 4 avfoundation ios avcapturesession swift
我目前正在使用 AVFoundation 捕获图像。由于我想在 Vision Framework 工作流程中使用捕获的图像,因此在将其转换为 UIImage 时需要其方向。我怎样才能做到这一点?从文档中我发现 AVCapturePhoto 有一个 .metadata 字典来访问该信息,但如果我使用相应的密钥,结果为零。
这是我的捕获例程的委托方法:
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
// capture image finished
print("Image captured.")
print(photo)
print(photo.metadata["kCGImagePropertyOrientation"]) // CGImageProperties for metadata keys for value retrieval.
Run Code Online (Sandbox Code Playgroud)
我在“CGImageProperties>Individual Image Properties”下找到了该键。打印(照片)确实向我显示了实际上已捕获的图像,返回:
AVCapturePhoto:0x1c1013940 点:98386.095931 1/1 设置:uid:3 照片:{4032x3024 SIS:ON}
请用 Swift 回答。:)
谢谢!
小智 5
我认为,您正在寻找的是:
photo.metadata["Orientation"]
Run Code Online (Sandbox Code Playgroud)
或者
photo.metadata[String(kCGImagePropertyOrientation)]
Run Code Online (Sandbox Code Playgroud)
我希望它能帮助你。
最好的!阿尼娅
| 归档时间: |
|
| 查看次数: |
1465 次 |
| 最近记录: |