Hello,
I am trying to play around with the Live Text API according to this docs - https://developer.apple.com/documentation/visionkit/enabling_live_text_interactions_with_images?changes=latest_minor
But it always fails with [api] -[CIImage initWithCVPixelBuffer:options:] failed because the buffer is nil.
I am running this on a UIImage instance that I got from VNDocumentCameraViewController.
This is my current implementation that I run after the scanned image is displayed:
private func setupLiveText() {
guard let image = imageView.image else {
return
}
let interaction = ImageAnalysisInteraction()
imageView.addInteraction(interaction)
Task {
let configuration = ImageAnalyzer.Configuration([.text])
let analyzer = ImageAnalyzer()
do {
let analysis = try await analyzer.analyze(image, configuration: configuration)
DispatchQueue.main.async {
interaction.analysis = analysis
}
} catch {
print(error.localizedDescription)
}
}
}
It does not fail, it returns non-nil analysis object, but setting it to the interaction does nothing.
I am testing this on iPhone SE 2020 which has the A13 chip. This feature requires A12 and up.