gpt4 book ai didi

ios - 以编程方式创建 ARReferenceImage

转载 作者:搜寻专家 更新时间:2023-10-31 22:17:58 25 4
gpt4 key购买 nike

我正在从数据库下载图像并想将它们用作 ARReferenceImage,而不是手动将它们添加到 Xcode Assets 文件夹。

代码

    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)

关于ios - 以编程方式创建 ARReferenceImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50181853/

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