Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>take a look at my example:</p> <p><a href="https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/note/NoteEditorActivity.java" rel="nofollow">https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/note/NoteEditorActivity.java</a></p> <p>What I did was call the camera, take a photo, get the photo and pass it to my <code>OCRTask</code> class (an AsyncTask) which calls the <code>TessBaseAPI</code></p> <pre><code> public void callCamera() { Log.d(TAG, "Starting camera..."); Intent cameraIntent = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, REQUEST_OCR); } </code></pre> <p><a href="https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/note/OCRTask.java" rel="nofollow">https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/note/OCRTask.java</a></p> <p>(A bit long if I post the entire <code>OCRTask</code> class code here, so just read it in Github, maybe?)</p> <p>And handled the result afterwards</p> <pre><code> @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { /* bunch of other codes */ if (requestCode == REQUEST_OCR) { if (resultCode == RESULT_OK) { Bitmap x = (Bitmap) data.getExtras().get("data"); new OCRTask(this, x, this).execute(); } } } </code></pre> <p>I just added the text it recognized to my <code>EditText</code></p> <pre><code> @Override public void onFinishRecognition(String recognizedText) { noteView.setText(noteView.getText() + " " + recognizedText); } </code></pre> <hr> <p><em>Here are the classes</em></p> <p><a href="https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/note/NoteEditorActivity.java" rel="nofollow">NoteEditor (calls the Camera intent)</a></p> <p><a href="https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/note/OCRTask.java" rel="nofollow">OCRTask (calls the <code>TessBaseApi</code>, this is your main concern)</a></p> <p><a href="https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/note/OCRCallback.java" rel="nofollow">OCRCallback (Adds the text to my <code>EditText</code> after <code>OCRTask</code> finishes)</a></p> <p><a href="https://github.com/akiwarheit/plug-notes-android/blob/master/src/com/plug/utils/FileManager.java" rel="nofollow">FileManager (util method)</a></p> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload