我想修改由Google提供的设备上文本识别示例,链接在这里,使其能够与实时摄像头流一起工作。
当将相机对准文本(适用于图像示例)时,我的控制台会在运行过程中产生以下流,最终会耗尽内存:
当将相机对准文本(适用于图像示例)时,我的控制台会在运行过程中产生以下流,最终会耗尽内存:
2018-05-16 10:48:22.129901+1200 TextRecognition[32138:5593533] An empty result returned from from GMVDetector for VisionTextDetector.
这是我的视频捕获方法:func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
if let textDetector = self.textDetector {
let visionImage = VisionImage(buffer: sampleBuffer)
let metadata = VisionImageMetadata()
metadata.orientation = .rightTop
visionImage.metadata = metadata
textDetector.detect(in: visionImage) { (features, error) in
guard error == nil, let features = features, !features.isEmpty else {
// Error. You should also check the console for error messages.
// ...
return
}
// Recognized and extracted text
print("Detected text has: \(features.count) blocks")
// ...
}
}
}
这样做是否正确?