'ARFrame' 类型的值没有成员 'viewTrans'
Value of type 'ARFrame' has no member 'viewTrans'
我不知道如何解决这个错误:
Value of type 'ARFrame' has no member 'viewTrans'
当我尝试用谷歌搜索错误时,没有任何结果。下面是一个代码片段,我在产生此错误的行的正上方放置了一个名为 //ERROR
的注释。
var viewTrans : CGAffineTransform? = nil
func session(_ session: ARSession, didUpdate frame: ARFrame) {
let depthData = frame.capturedDepthData
if depthData != nil {
self.displayCalibrationData(depthData: (frame.capturedDepthData?.cameraCalibrationData)!, colorData: frame.camera.intrinsics)
// Render depth data to background texture (not quite as fast as using Metal textures)
let depthBuffer : CVPixelBuffer = depthData!.depthDataMap
let colorBuffer : CVPixelBuffer = frame.capturedImage
// Output scene dimensions
let frameWidth = sceneView.frame.size.width
let frameHeight = sceneView.frame.size.height
let targetSize = CGSize(width: frameWidth, height: frameHeight)
// ERROR
self.viewTrans = frame.viewTrans(for: UIInterfaceOrientation.portrait, viewportSize: targetSize)
renderDepthColorOverlay(depthBuffer: depthBuffer, colorBuffer: colorBuffer, viewTrans: self.viewTrans!, targetSize: targetSize)
}
}
ARFrame 没有任何 viewTrans 方法:
https://developer.apple.com/documentation/arkit/arframe
相反,您应该更改此行:
self.viewTrans = frame.viewTrans(for: UIInterfaceOrientation.portrait, viewportSize: targetSize)
为此:
self.viewTrans = frame.displayTransform(for: UIInterfaceOrientation.portrait, viewportSize: targetSize)
displayTransform(for:viewportSize:)
Returns an affine transform for converting between normalized image coordinates and a coordinate space appropriate for rendering the camera image onscreen.
看这里:https://developer.apple.com/documentation/arkit/arframe/2923543-displaytransform
我不知道如何解决这个错误:
Value of type 'ARFrame' has no member 'viewTrans'
当我尝试用谷歌搜索错误时,没有任何结果。下面是一个代码片段,我在产生此错误的行的正上方放置了一个名为 //ERROR
的注释。
var viewTrans : CGAffineTransform? = nil
func session(_ session: ARSession, didUpdate frame: ARFrame) {
let depthData = frame.capturedDepthData
if depthData != nil {
self.displayCalibrationData(depthData: (frame.capturedDepthData?.cameraCalibrationData)!, colorData: frame.camera.intrinsics)
// Render depth data to background texture (not quite as fast as using Metal textures)
let depthBuffer : CVPixelBuffer = depthData!.depthDataMap
let colorBuffer : CVPixelBuffer = frame.capturedImage
// Output scene dimensions
let frameWidth = sceneView.frame.size.width
let frameHeight = sceneView.frame.size.height
let targetSize = CGSize(width: frameWidth, height: frameHeight)
// ERROR
self.viewTrans = frame.viewTrans(for: UIInterfaceOrientation.portrait, viewportSize: targetSize)
renderDepthColorOverlay(depthBuffer: depthBuffer, colorBuffer: colorBuffer, viewTrans: self.viewTrans!, targetSize: targetSize)
}
}
ARFrame 没有任何 viewTrans 方法: https://developer.apple.com/documentation/arkit/arframe
相反,您应该更改此行:
self.viewTrans = frame.viewTrans(for: UIInterfaceOrientation.portrait, viewportSize: targetSize)
为此:
self.viewTrans = frame.displayTransform(for: UIInterfaceOrientation.portrait, viewportSize: targetSize)
displayTransform(for:viewportSize:) Returns an affine transform for converting between normalized image coordinates and a coordinate space appropriate for rendering the camera image onscreen.
看这里:https://developer.apple.com/documentation/arkit/arframe/2923543-displaytransform