Esempio n. 1
0
  @Override
  public void OnVisionActionComplete(VisionAction op) {
    Log.d(TAG, "op completed");

    Note client = (Note) cvExecutor.getClient(op);
    client.processingFinished();

    final NoteListAdapter adapter = noteListAdapter;
    runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            adapter.notifyDataSetChanged();
          }
        });

    // TODO result dispatcher
    /*try {
        final Bitmap resultImage = (Bitmap) op.get();
        Log.d(TAG, "got result");

        // display result
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ImageView resultView = (ImageView) findViewById(R.id.img_raw); // FIXME should be img_result
                resultView.setImageBitmap(resultImage);
            }
        });
    } catch(InterruptedException e) {
        Log.e(TAG, Log.getStackTraceString(e));
    } catch(ExecutionException e) {
        Log.e(TAG, Log.getStackTraceString(e));
    }*/
  }
Esempio n. 2
0
  public void importPhoto(Intent imageReturnedIntent) {
    Uri imageURI = imageReturnedIntent.getData();
    String[] filePathColumn = {MediaStore.Images.Media.DATA};

    Cursor cursor = getContentResolver().query(imageURI, filePathColumn, null, null, null);
    cursor.moveToFirst();

    int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
    String filePath = cursor.getString(columnIndex);
    cursor.close();

    Bitmap selectedImage = BitmapFactory.decodeFile(filePath);

    // create a new note
    VisionAction processing = new OpDeskew(this, selectedImage);
    String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
    Note newNote = new Note(imageURI.toString(), imageURI, processing, date);

    // make thumbnail
    newNote.thumbnail =
        Bitmap.createScaledBitmap(selectedImage, (int) (0.80 * noteList.getWidth()), 64, false);

    // start processing
    cvExecutor.execute(newNote, processing);

    // add to list of notes
    notes.add(newNote);
    noteListAdapter.notifyDataSetChanged();
  }