ios - 以编程方式创建 ARReferenceImage
问题描述
我正在从数据库中下载图像并希望将它们用作 ARReferenceImage,而不是手动将它们添加到 Xcode 资产文件夹。
代码
let image = #imageLiteral(resourceName: "mike")
let cgImage = image.cgImage
guard let referenceImages = ARReferenceImage.init(cgImage, orientation: .portrait, physicalWidth: 100) else {
fatalError("Failed to load image")
}
错误
对成员 'init(_:orientation:physicalWidth:)' 的模糊引用
解决方案
CGImagePropertyOrientation 不支持.portrait
请使用以下支持:
public enum CGImagePropertyOrientation : UInt32 {
case up // 0th row at top, 0th column on left - default orientation
case upMirrored // 0th row at top, 0th column on right - horizontal flip
case down // 0th row at bottom, 0th column on right - 180 deg rotation
case downMirrored // 0th row at bottom, 0th column on left - vertical flip
case leftMirrored // 0th row on left, 0th column at top
case right // 0th row on right, 0th column at top - 90 deg CW
case rightMirrored // 0th row on right, 0th column on bottom
case left // 0th row on left, 0th column at bottom - 90 deg CCW
}
你的代码:
let referenceImages = ARReferenceImage(cgImage!, orientation: CGImagePropertyOrientation.up, physicalWidth: 100)
或者
let referenceImages = ARReferenceImage.init(cgImage!, orientation: CGImagePropertyOrientation.up, physicalWidth: 100)
推荐阅读
- docker - Jenkins + Docker:无法在 tcp://dind:2375 连接到 Docker 守护程序。docker 守护进程是否正在运行?
- c++ - p_threads初始化中向量和数组的区别
- javascript - 如何在 CountUp JS 包中添加逗号
- javascript - 未捕获的 FirebaseError:Firebase:名为“[DEFAULT]”的 Firebase 应用程序已存在(应用程序/重复应用程序)
- python - Pandas 按列分组并计算值
- c# - 如何检查 PDF 是否正确加载?
- python - 无法使用 pandas 读取 cab 文件
- typescript - 如何在对象打字稿代码中找到元素
- windows - C ++ Windows从任务管理器中的应用程序选项卡中检测到杀戮?
- c# - 无法从“ListMapColor.MyContainer”转换为“System.Drawing.Color”