mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Optimize text recognition
This commit is contained in:
parent
f4301ce632
commit
6630833866
@ -322,8 +322,10 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||||||
strongSelf.recognizedContentNode?.removeFromSupernode()
|
strongSelf.recognizedContentNode?.removeFromSupernode()
|
||||||
if !results.isEmpty {
|
if !results.isEmpty {
|
||||||
let size = strongSelf.imageNode.bounds.size
|
let size = strongSelf.imageNode.bounds.size
|
||||||
let recognizedContentNode = RecognizedContentContainer(size: size, recognitions: results, presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, present: { c, a in
|
let recognizedContentNode = RecognizedContentContainer(size: size, recognitions: results, presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, present: { [weak self] c, a in
|
||||||
|
if let strongSelf = self {
|
||||||
strongSelf.galleryController()?.presentInGlobalOverlay(c, with: a)
|
strongSelf.galleryController()?.presentInGlobalOverlay(c, with: a)
|
||||||
|
}
|
||||||
}, performAction: { [weak self] string, action in
|
}, performAction: { [weak self] string, action in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
|
@ -302,6 +302,7 @@ private func recognizeContent(in image: UIImage) -> Signal<[RecognizedContent],
|
|||||||
let _ = barcodeResult.swap(mappedResults)
|
let _ = barcodeResult.swap(mappedResults)
|
||||||
completion()
|
completion()
|
||||||
}
|
}
|
||||||
|
barcodeRequest.preferBackgroundProcessing = true
|
||||||
requests.append(barcodeRequest)
|
requests.append(barcodeRequest)
|
||||||
|
|
||||||
if #available(iOS 13.0, *) {
|
if #available(iOS 13.0, *) {
|
||||||
@ -310,6 +311,7 @@ private func recognizeContent(in image: UIImage) -> Signal<[RecognizedContent],
|
|||||||
let _ = textResult.swap(mappedResults)
|
let _ = textResult.swap(mappedResults)
|
||||||
completion()
|
completion()
|
||||||
}
|
}
|
||||||
|
textRequest.preferBackgroundProcessing = true
|
||||||
textRequest.usesLanguageCorrection = true
|
textRequest.usesLanguageCorrection = true
|
||||||
requests.append(textRequest)
|
requests.append(textRequest)
|
||||||
} else {
|
} else {
|
||||||
@ -320,7 +322,11 @@ private func recognizeContent(in image: UIImage) -> Signal<[RecognizedContent],
|
|||||||
try? handler.perform(requests)
|
try? handler.perform(requests)
|
||||||
|
|
||||||
return ActionDisposable {
|
return ActionDisposable {
|
||||||
|
if #available(iOS 13.0, *) {
|
||||||
|
for request in requests {
|
||||||
|
request.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user