我有一个视图控制器,ARSKView
其ARSession
配置如下:
let configuration = ARWorldTrackingSessionConfiguration()
arskView.session.run(configuration)
在其相关的SKScene
我有这个方法实现:
override func update(_ currentTime: TimeInterval) {
guard let arskView = self.view as? ARSKView else {
return
}
if let currentFrame = arskView.session.currentFrame {
let capturedImage = currentFrame.capturedImage
var requestOptions: [VNImageOption : Any] = [:]
if let cameraData = CMGetAttachment(capturedImage, kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix, nil) {
requestOptions = [.cameraIntrinsics : cameraData]
}
let request = VNDetectTextRectanglesRequest { [weak self] (request, error) in
self?.detectTextHandler(request: request, error: error)
}
request.reportCharacterBoxes = true
let imageRequestHandler = VNImageRequestHandler(cvPixelBuffer: capturedImage, orientation: 6, options: requestOptions)
do {
try imageRequestHandler.perform([request])
} catch {
print(error)
}
}
}
然后,一些逻辑来绘制包裹检测到的文本的矩形。我在这篇文章中发现了这样的逻辑,其中ARKit
并ARSKView
没有使用,而是使用了AVCaptureSession
and AVCaptureVideoPreviewLayer
。ARKit
当您运行该示例时,与我使用and运行项目时相比,相机质量更好,文本框绘制更准确ARSKView
。
我需要使用ARKit
with SpriteKit
,但是当我将相机靠近文本时,它们会显示为模糊,并且通常包装单词的框被绘制得很错位。
有什么办法可以改善吗?