Создайте ARReferenceImage программно - PullRequest
0 голосов
/ 04 мая 2018

Я загружаю изображения из базы данных и хочу использовать их как 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")
    }

Error

Неоднозначная ссылка на член 'init (_: ориентация: физическая ширина:)'

Ответы [ 2 ]

0 голосов
/ 04 мая 2018

CGImagePropertyOrientation не имеет члена с именем .portrait.

Согласно документации он имеет .up, .upMirrored, .down, .downMirrored, .leftMirrored, .right, .rightMirrored, .left. Если вы используете один из них в инициализаторе, он должен работать.

Например:

let referenceImage = ARReferenceImage(cgImage, orientation: .up, physicalWidth: 100)
0 голосов
/ 04 мая 2018

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)
...