gustavomazzoni / cordova-plugin-tesseract

Cordova Plugin for OCR process using Tesseract
77 stars 34 forks source link

ReferenceError: deferred is not defined [ionic3] #43

Closed indraraj26 closed 5 years ago

indraraj26 commented 5 years ago

Dear gustavomazzoni,

i have defined these variable at the top of file

declare var TesseractPlugin: any;
var language = 'eng';

i get deferred not defined. when i declare this too at the top of file still i am getting deferred is not defined. declare var deferred: any;

 onCamera() {
    TesseractPlugin.loadLanguage(language, function(response) {
      deferred.resolve(response);
    }, function(reason) {
      deferred.reject('Error on loading OCR file for your language. ' + reason);
    });

    const options: CameraOptions = {
      quality: 100,
      destinationType: this.camera.DestinationType.FILE_URI,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }

    this.camera.getPicture(options).then((imageData) => {
        console.log(imageData)
        TesseractPlugin.recognizeText(imageData, language, function(recognizedText) {
          deferred.resolve(recognizedText);
          console.log(deferred.resolve(recognizedText))
          console.log(recognizedText);
        }, function(reason) {
          deferred.reject('Error on recognizing text from image. ' + reason);
        });

    }, (err) => {
      console.log(err)
    });
   }