このsample Android programでは、デバイスのカメラを使用して、com.google.android.gms:play-services-vision
ライブラリを通じて光学式文字認識を実行します。GoogleサンプルのAndroidコードでOCR Detector.Processorからデータを返す方法
Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue());
上記のプロセスは、OcrCaptureActivity
によって開始されています:私は、ロギング使用して識別されたテキストを参照することができる午前visionSamples\ocr-codelab\ocr-reader-complete\app\src\main\java\com\google\android\gms\samples\vision\ocrreader\OcrDetectorProcessor.receiveDetections()
で
TextRecognizer textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay));
CameraSource mCameraSource = new CameraSource.Builder(getApplicationContext(), textRecognizer)/* snip */.build();
CameraSourcePreview mPreview = (CameraSourcePreview) findViewById(R.id.preview);
mPreview.start(mCameraSource, mGraphicOverlay);
は、だから我々は "のそれ以上のセットを参照してください「もの」は、アクティビティをクランクアップする典型的な方法ではありません。
この質問はバックOcrCaptureActivity
からOcrDetectorProcessor
からの結果をフィードする方法についてです。
私は、OcrCaptureActivity
にonActivityResult()
を追加しようとしたが、それは発生しません:OcrDetectorProcessor
がActivity
ないので、私は単純に新しいテントを作成し、setResult()
方法を使用することはできません
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.v(TAG, ">>>>>>> OnActivityResult intent: " + data);
}
。
適時に(Androidの戻るボタンが押されたときに)実行されるOcrDetectorProcessor.release()
メソッドがありますが、親プロセスと通信する方法がわかりません。