I am downloading images from the database and want to use them as ARReferenceImage, instead of manually adding them to Xcode asset folder.
Code
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
Ambiguous reference to member 'init(_:orientation:physicalWidth:)'
CGImagePropertyOrientation not support .portrait Please use below support:
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
}
Your code:
let referenceImages = ARReferenceImage(cgImage!, orientation: CGImagePropertyOrientation.up, physicalWidth: 100)
Or
let referenceImages = ARReferenceImage.init(cgImage!, orientation: CGImagePropertyOrientation.up, physicalWidth: 100)
CGImagePropertyOrientation doesn't have a member named .portrait.
According to the documentation it has .up, .upMirrored, .down, .downMirrored, .leftMirrored, .right, .rightMirrored, .left. If you use one of these in your initializer it should work.
For example:
let referenceImage = ARReferenceImage(cgImage, orientation: .up, physicalWidth: 100)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With