इस दस्तावेज़ में, iOS पर Google Mobile Vision (GMV) से ML Kit पर अपने प्रोजेक्ट माइग्रेट करने के लिए ज़रूरी चरणों के बारे में बताया गया है.
ज़रूरी शर्तें
अपना कोड माइग्रेट करने से पहले, पक्का करें कि आपने ये ज़रूरी शर्तें पूरी कर ली हों:
- ML Kit, Xcode 13.2.1 या इसके बाद के वर्शन पर काम करता है.
- ML Kit, iOS के 15.5 या इसके बाद के वर्शन पर काम करता है.
- ML Kit, 32-बिट वाले आर्किटेक्चर (i386 और armv7) पर काम नहीं करता. ML Kit, 64-बिट वाले आर्किटेक्चर (x86_64 और arm64) पर काम करता है.
cocoapods अपडेट करना
अपने ऐप्लिकेशन की Podfile में, iOS के लिए ML Kit के cocoapods की डिपेंडेंसी अपडेट करें:
| एपीआई | जीएमवी पॉड | ML Kit पॉड |
|---|---|---|
| बारकोड स्कैन करने की सुविधा | GoogleMobileVision/BarcodeDetector |
GoogleMLKit/BarcodeScanning |
| चेहरे की पहचान | GoogleMobileVision/FaceDetector |
GoogleMLKit/FaceDetection |
| टेक्स्ट की पहचान करने की सुविधा | GoogleMobileVision/TextDetector |
GoogleMLKit/TextRecognition |
एपीआई में हुए सामान्य बदलाव
ये बदलाव सभी एपीआई पर लागू होते हैं:
- GMV के इन्फ़रेंस एपीआई, इनपुट के तौर पर
UIImageयाCMSampleBufferRefलेते हैं. ML Kit, इन्हेंMLKVisionImageमें रैप करता है और इसे इनपुट के तौर पर लेता है. - GMV,
NSDictionaryअलग-अलग डिटेक्टर के विकल्प पास करने के लिए इस्तेमाल करता है. ML Kit, इसके लिए खास विकल्प वाली क्लास का इस्तेमाल करता है. - डिटेक्टर बनाते समय, GMV, डिटेक्टर का टाइप,
GMVDetectorकी एक ही क्लास को पास करता है. ML Kit, डिटेक्टर, स्कैनर, और पहचान करने वाले इंस्टेंस बनाने के लिए, खास क्लास का इस्तेमाल करता है. - GMV के एपीआई, सिर्फ़ सिंक्रोनस तरीके से पहचान करने की सुविधा देते हैं. ML Kit के इन्फ़रेंस एपीआई को सिंक्रोनस और एसिंक्रोनस, दोनों तरीकों से कॉल किया जा सकता है.
- GMV,
AVCaptureVideoDataOutputको बढ़ाता है और एक ही समय में कई बार पहचान करने के लिए, मल्टी-डिटेक्टर फ़्रेमवर्क उपलब्ध कराता है. ML Kit, इस तरह के कोई भी मैकेनिज़्म उपलब्ध नहीं कराता. हालांकि, डेवलपर चाहे, तो इस सुविधा को लागू कर सकता है.
एपीआई के हिसाब से हुए बदलाव
इस सेक्शन में, हर Vision API के लिए, GMV और ML Kit की क्लास और तरीकों के बारे में बताया गया है. साथ ही, इसमें एपीआई को शुरू करने का तरीका भी दिखाया गया है.
FaceDetector
इस उदाहरण में दिखाए गए तरीके से, शुरू करने के लिए कोड फिर से लिखें:
GMV
NSDictionary *options = @{ GMVDetectorFaceMode : @(GMVDetectorFaceAccurateMode), GMVDetectorFaceClassificationType : @(GMVDetectorFaceClassificationAll), GMVDetectorFaceLandmarkType : @(GMVDetectorFaceLandmarkAll) }; GMVDetector *faceDetector = [GMVDetector detectorOfType:GMVDetectorTypeFace options:options];
ML Kit
MLKFaceDetectorOptions *options = [[MLKFaceDetectorOptions alloc] init]; options.performanceMode = MLKFaceDetectorPerformanceModeAccurate; options.classificationMode = MLKFaceDetectorClassificationModeAll; options.landmarkMode = MLKFaceDetectorLandmarkModeAll; MLKFaceDetector *faceDetector = [MLKFaceDetector faceDetectorWithOptions:options];
GMVDetector में, पहचान करने के दो अलग-अलग एपीआई होते हैं. ये दोनों, सिंक्रोनस तरीके से काम करते हैं:
- (nullable NSArray<__kindof GMVFeature *> *) featuresInImage:(UIImage *)image options:(nullable NSDictionary *)options; - (nullable NSArray<__kindof GMVFeature *> *) featuresInBuffer:(CMSampleBufferRef)sampleBuffer options:(nullable NSDictionary *)options;
GMVDetector को MLKFaceDetector से बदलें.
इन्फ़रेंस एपीआई को सिंक्रोनस या एसिंक्रोनस तरीके से कॉल किया जा सकता है.
सिंक्रोनस
- (nullable NSArray<MLKFace *> *) resultsInImage:(MLKVisionImage *)image error:(NSError **)error;
एसिंक्रोनस
- (void)processImage:(MLKVisionImage *)image Completion: (MLKFaceDetectionCallback)completion NS_SWIFT_NAME(process(_:completion:));
इन क्लास, तरीकों, और नामों में बदलाव करें:
BarcodeDetector
इस उदाहरण में दिखाए गए तरीके से, शुरू करने के लिए कोड फिर से लिखें:
GMV
NSDictionary *options = @{ GMVDetectorBarcodeFormats : @(GMVDetectorBarcodeFormatCode128 | GMVDetectorBarcodeFormatQRCode) }; GMVDetector *barcodeDetector = [GMVDetector detectorOfType:GMVDetectorTypeBarcode options:options];
ML Kit
MLKBarcodeScannerOptions *options = [[MLKBarcodeScannerOptions alloc] init]; options.formats = MLKBarcodeFormatCode128 | MLKBarcodeFormatQRCode; MLKBarcodeScanner *barcodeScanner = [MLKBarcodeScanner barcodeScannerWithOptions:options];
GMVDetector में, पहचान करने के दो अलग-अलग एपीआई होते हैं. ये दोनों, सिंक्रोनस तरीके से काम करते हैं:
- (nullable NSArray<__kindof GMVFeature *> *) featuresInImage:(UIImage *)image options:(nullable NSDictionary *)options; - (nullable NSArray<__kindof GMVFeature *> *) featuresInBuffer:(CMSampleBufferRef)sampleBuffer options:(nullable NSDictionary *)options;
GMVDetector को
MLKBarcodeScanner से बदलें.
इन्फ़रेंस एपीआई को सिंक्रोनस या एसिंक्रोनस तरीके से कॉल किया जा सकता है.
सिंक्रोनस
- (nullable NSArray<MLKBarcode *> *) resultsInImage:(MLKVisionImage *)image error:(NSError **)error;
एसिंक्रोनस
- (void)processImage:(MLKVisionImage *)image Completion: (MLKBarcodeScanningCallback)completion NS_SWIFT_NAME(process(_:completion:));
इन क्लास, तरीकों, और नामों में बदलाव करें:
TextRecognition
इस उदाहरण में दिखाए गए तरीके से, शुरू करने के लिए कोड फिर से लिखें:
GMV
GMVDetector *textDetector = [GMVDetector detectorOfType:GMVDetectorTypeText options:nil];
ML Kit
MLKTextRecognizer *textRecognizer = [MLKTextRecognizer textRecognizer];
GMVDetector में, पहचान करने के दो अलग-अलग एपीआई होते हैं. ये दोनों, सिंक्रोनस तरीके से काम करते हैं:
- (nullable NSArray<__kindof GMVFeature *> *) featuresInImage:(UIImage *)image options:(nullable NSDictionary *)options; - (nullable NSArray<__kindof GMVFeature *> *) featuresInBuffer:(CMSampleBufferRef)sampleBuffer options:(nullable NSDictionary *)options;
GMVDetector को
MLKTextRecognizer से बदलें.
इन्फ़रेंस एपीआई को सिंक्रोनस या एसिंक्रोनस तरीके से कॉल किया जा सकता है.
सिंक्रोनस
- (nullable MLKText *) resultsInImage:(MLKVisionImage *)image error:(NSError **)error;
एसिंक्रोनस
- (void)processImage:(MLKVisionImage *)image Completion: (MLKTextRecognitionCallback)completion NS_SWIFT_NAME(process(_:completion:));
इन क्लास, तरीकों, और नामों में बदलाव करें:
| GMV | ML Kit |
|---|---|
GMVDetectorImageOrientation
|
MLKVisionImage.orientation
|
GMVTextBlockFeature
|
MLKTextBlock
|
GMVTextElementFeature
|
MLKTextElement
|
GMVTextLineFeature
|
MLKTextLine
|
सहायता पाना
अगर आपको कोई समस्या आती है, तो हमारे कम्यूनिटी पेज पर जाएं. इस पेज पर, हमसे संपर्क करने के लिए उपलब्ध चैनलों के बारे में बताया गया है.