gpt4 book ai didi

ios - 如何从 AVCapturePhoto 获取元数据值?

转载 作者:可可西里 更新时间:2023-11-01 00:56:22 27 4
gpt4 key购买 nike

我目前正在使用 AVFoundation 捕获图像。由于我想在 Vision Framework 工作流中使用捕获的图像,因此在将其转换为 UIImage 时需要它的方向。我怎样才能做到这一点?从文档中我发现 AVCapturePhoto 有一个 .metadata 字典来访问该信息,但如果我使用相应的键,我会得到 nil 作为结果。

这是我的捕获例程的委托(delegate)方法:

    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.

我在“CGImageProperties>Individual Image Properties”下找到了 key 。 print(photo) 确实向我展示了实际拍摄的图像,并返回:

AVCapturePhoto: 0x1c1013940 pts:98386.095931 1/1 settings:uid:3 photo:{4032x3024 SIS:ON}

请用 Swift 回答。 :)

谢谢!

最佳答案

我想,你要找的是:

photo.metadata["Orientation"]

photo.metadata[String(kCGImagePropertyOrientation)]

希望对您有所帮助。

最好!阿尼亚

关于ios - 如何从 AVCapturePhoto 获取元数据值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46837649/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com