مرجع إطار عمل MLKitText learning Common
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
TextRecognizer
class TextRecognizer : NSObject
أداة للتعرّف على النص في الصورة
-
لعرض أداة التعرّف على النص بالخيارات المحددة.
الاستخدام المتزامن لمثيلات TextRecognizer
متعددة بلغة مختلفة
لا يُنصح باستخدامها، لأنّها قد تؤدي إلى تدهور الأداء.
بيان الإفصاح
Swift
class func textRecognizer(options: MLKCommonTextRecognizerOptions) -> Self
المعلمات
options
|
خيارات ضبط أداة التعرّف على النص
|
القيمة المعروضة
أداة التعرّف على النص التي تم ضبطها مع الخيارات المحدّدة.
-
لمعالجة الصورة المحددة للتعرّف على النص.
المعلمات
image
|
|
completion
|
يمكن للمعالج معاودة الاتصال في قائمة الانتظار الرئيسية عند اكتمال التعرف على النص.
|
-
عرض نتيجة التعرف على النص في الصورة المحددة أو nil
إذا كان هناك خطأ. النص
التعرف على الهوية بشكل متزامن في سلسلة الاتصال.
يُنصح باستدعاء هذه الطريقة خارج سلسلة التعليمات الرئيسية لتجنّب حظر واجهة المستخدم. نتيجة لذلك، أُنشئت مكتبة مات بلوت ليب في
النتيجة، يتم رفع NSException
إذا تم استدعاء هذه الطريقة في سلسلة التعليمات الرئيسية.
المعلمات
image
|
الصورة التي يتم الحصول على نتائج فيها.
|
error
|
مَعلمة خطأ اختيارية تتمّ تعبئتها عند حدوث خطأ في الحصول على النتائج.
|
القيمة المعروضة
ينتج عن التعرّف على النص الصورة المحدّدة أو nil
إذا كان هناك خطأ.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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."]]