- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我目前正在使用 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/
我正在尝试实现一些类似于 snapchat 的自定义相机。我不明白为什么我的图像在继续过程中总是为零。也许一双新的眼睛可能会有所帮助,因为我已经为此工作了两天...... 当我点击拍照按钮(运行“li
我目前正在使用 AVFoundation 捕获图像。由于我想在 Vision Framework 工作流中使用捕获的图像,因此在将其转换为 UIImage 时需要它的方向。我怎样才能做到这一点?从文档
我正在尝试用 Swift 编写一个 iOS 应用程序,让用户可以拍照,然后我将在图像上叠加一些额外的数据。我希望图像包含位置数据。我正在使用 AVCapturePhoto,我可以在文档中看到它有一些元
我调用 AVFoundation的委托(delegate)方法来处理照片捕获,但我在转换 AVCapturePhoto 时遇到了困难它生成一个UIImage方向正确。虽然下面的例程是成功的,但我总是得
如标题所示,我正在尝试从方法的输出中检索捕获的照片的 CVPixelBuffer: AVCapturePhotoCaptureDelegate.photoOutput(_输出:AVCapturePho
我是一名优秀的程序员,十分优秀!