2017-01-04 15 views
0

私はイオンアプリを開発しようとしています。光学式文字認識(OCR)を追加したいと思います。Ionic - OCR:ReferenceError TesseractPluginが定義されていません

私はコルドバのカメラプラグインをインストールする必要があり、私はこのgithubのプロジェクト(たTesseract)を使用したいと思います:https://github.com/gustavomazzoni/cordova-plugin-tesseract

しかし、私はこの機能を使用する場合、私は私のJavaScriptコンソールに次のエラーがあります。

ionic.bundle.js:26799 ReferenceError: TesseractPlugin is not defined

次のコマンドを表示:cordova plugin list:ここ

cordova-plugin-camera 2.3.1 "Camera"

cordova-plugin-compat 1.1.0 "Compat"

cordova-plugin-tesseract 0.0.1 "Tesseract Plugin"

phonegap-plugin-barcodescanner 6.0.5 "BarcodeScanner"

は私のコントローラのコードです:

'Use Strict'; 
 

 
angular.module('App') 
 

 
    .controller('CameraOCRController', function($scope, $cordovaCamera) { 
 

 

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

 
     $scope.takePhoto = function() { 
 
      var options = { 
 
       quality: 75, 
 
       destinationType: Camera.DestinationType.DATA_URL, 
 
       sourceType: Camera.PictureSourceType.CAMERA, 
 
       allowEdit: true, 
 
       encodingType: Camera.EncodingType.JPEG, 
 
       targetWidth: 300, 
 
       targetHeight: 300, 
 
       popoverOptions: CameraPopoverOptions, 
 
       saveToPhotoAlbum: false 
 
      }; 
 
      $cordovaCamera.getPicture(options).then(function (imageData) { 
 
       $scope.imgURI = "data:image/jpeg;base64," + imageData; 
 

 
       TesseractPlugin.recognizeText(imageData, language, function(recognizedText) { 
 
        $scope.text = recognizedText; 
 
       }, function(reason) { 
 
        alert('Error on recognizing text from image. ' + reason); 
 
       }); 
 

 
      }, function (err) { 
 
       alert("An error occured. Show a message to the user"+err); 
 
      }); 
 
     }; 
 

 
    });

私はエラーが表示されません。

+0

この問題を修正しましたか? – VLR

答えて

0

プラグインを参照する前にdevicereadyが起動するのを待っていますか?

関連する問題