Referencia del framework MLKitTextRecognitionCommon
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
TextRecognizer
class TextRecognizer : NSObject
Un reconocedor de texto que reconoce texto en una imagen.
-
Muestra un reconocedor de texto con las opciones determinadas.
Uso simultáneo de varias instancias de TextRecognizer
con diferentes idiomas
no se recomienda, ya que puede provocar una degradación del rendimiento.
Declaración
Swift
class func textRecognizer(options: MLKCommonTextRecognizerOptions) -> Self
Parámetros
options
|
Opciones para configurar el reconocedor de texto.
|
Valor de retorno
Un reconocedor de texto configurado con las opciones determinadas.
-
Procesa la imagen determinada para el reconocimiento de texto.
Parámetros
image
|
La imagen que se procesará.
|
completion
|
Controlador que se llamará en la cola principal cuando se complete el reconocimiento de texto.
|
-
Muestra el resultado de reconocimiento de texto en la imagen determinada o nil
si se produjo un error. El texto
el reconocimiento se realiza de forma síncrona en el subproceso de llamada.
Se recomienda llamar a este método fuera del subproceso principal para evitar bloquear la IU. Como
Como resultado, se genera una NSException
si se llama a este método en el subproceso principal.
Parámetros
image
|
La imagen en la que se deben obtener resultados.
|
error
|
Es un parámetro de error opcional que se propaga cuando se produce un error cuando se obtienen los resultados.
|
Valor de retorno
El reconocimiento de texto muestra la imagen determinada o nil
si hubo un error.
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-25 (UTC)
[null,null,["Última actualización: 2025-07-25 (UTC)"],[[["\u003cp\u003e\u003ccode\u003eTextRecognizer\u003c/code\u003e identifies and extracts text within images.\u003c/p\u003e\n"],["\u003cp\u003eIt offers both synchronous and asynchronous processing options.\u003c/p\u003e\n"],["\u003cp\u003eConcurrent use with varying language settings may impact performance.\u003c/p\u003e\n"],["\u003cp\u003eDirect use on the main thread is discouraged due to potential UI blocking.\u003c/p\u003e\n"]]],["The `TextRecognizer` class recognizes text in images. It can be initialized with specific options via `textRecognizer(options:)`. The `process(_:)` method performs text recognition on an image asynchronously, while `results(in:)` performs it synchronously, returning the recognized text or `nil` if an error occurs. Concurrent usage of multiple `TextRecognizer` instances with different language options may reduce performance. `results(in:)` should not be called on the main thread.\n"],null,["# MLKitTextRecognitionCommon Framework Reference\n\nTextRecognizer\n==============\n\n class TextRecognizer : NSObject\n\nA text recognizer that recognizes text in an image.\n- `\n ``\n ``\n `\n\n ### [textRecognizer(options:)](#/c:objc(cs)MLKTextRecognizer(cm)textRecognizerWithOptions:)\n\n `\n ` \n Returns a text recognizer with the given options.\n\n Concurrent usage of multiple `TextRecognizer` instances with different language\n options is not recommended, since it may lead to performance degradation. \n\n #### Declaration\n\n Swift \n\n class func textRecognizer(options: MLKCommonTextRecognizerOptions) -\u003e Self\n\n #### Parameters\n\n |-----------------|----------------------------------------------|\n | ` `*options*` ` | Options for configuring the text recognizer. |\n\n #### Return Value\n\n An text recognizer configured with the given options.\n- `\n ``\n ``\n `\n\n ### [process(_:)](#/c:objc(cs)MLKTextRecognizer(im)processImage:completion:)\n\n `\n ` \n Processes the given image for text recognition. \n\n #### Declaration\n\n Swift \n\n func process(_ image: ../Protocols.html#/c:objc(pl)MLKCompatibleImage) async throws -\u003e MLKText\n\n #### Parameters\n\n |--------------------|-------------------------------------------------------------------------|\n | ` `*image*` ` | The image to process. |\n | ` `*completion*` ` | Handler to call back on the main queue when text recognition completes. |\n\n- `\n ``\n ``\n `\n\n ### [results(in:)](#/c:objc(cs)MLKTextRecognizer(im)resultsInImage:error:)\n\n `\n ` \n Returns text recognition result in the given image or `nil` if there was an error. The text\n recognition is performed synchronously on the calling thread.\n\n It is advised to call this method off the main thread to avoid blocking the UI. As a\n result, an `NSException` is raised if this method is called on the main thread. \n\n #### Declaration\n\n Swift \n\n func results(in image: ../Protocols.html#/c:objc(pl)MLKCompatibleImage) throws -\u003e MLKText\n\n #### Parameters\n\n |---------------|-------------------------------------------------------------------------------|\n | ` `*image*` ` | The image to get results in. |\n | ` `*error*` ` | An optional error parameter populated when there is an error getting results. |\n\n #### Return Value\n\n Text recognition result in the given image or `nil` if there was an error."]]