I am developing a function using Live Text. (I used ImageAnalyzer and ImageAnalysisInteraction.)
When executed, the following error log is displayed and the Live Text Button is displayed but not clicked or highlighted. That is, it does nothing.
[Unknown process name] Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.
[Unknown process name] If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable.
[api] -[CIImage initWithCVPixelBuffer:options:] failed because the buffer is nil.
Are there any possible causes and solutions for this not working? Or is there a setting I'm missing in order to use LiveText?
Below is part of the code. Changing preferredInteractionTypes to all types doesn't change anything.
UIImageViews are displayed by switching left and right through UIPageViewController and calling the LiveText function.
Task {
var analyzer:ImageAnalyzer? = ImageAnalyzer()
if analyzer == nil {
return
}
let configuration = ImageAnalyzer.Configuration([.text])
do {
let pAnalysis = try await analyzer!.analyze(image!, configuration: configuration)
DispatchQueue.main.async {
//interaction!.preferredInteractionTypes = .automatic
interaction.preferredInteractionTypes = .textSelection
//interaction!.preferredInteractionTypes = .dataDetectors
//interaction!.preferredInteractionTypes = [.textSelection, .dataDetectors]
//interaction.preferredInteractionTypes = [.textSelection, .dataDetectors, .automatic]
interaction.selectableItemsHighlighted = true
interaction.analysis = pAnalysis
interaction.setContentsRectNeedsUpdate()
}
} catch {}
analyzer = nil
}