// Called when a started intent returns
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    String message = null;
    if (resultCode != RESULT_OK) {
      Toast t = Toast.makeText(this, "Failed to load image", Toast.LENGTH_SHORT);
      t.show();
      return;
    }

    // Assign the view to change based on who sent the request
    // There are two positions possibles
    int position = requestCode;

    // Check if file path or uri image source
    String filePath = data.getExtras().getString(BaseImageTaker.INTENT_RESULT_IMAGE_PATH);

    // Depending on how image was obtained,
    // obtain a Bitmap image of object
    // Getting source of the image

    Bitmap image = null;
    // Decode File path f
    if (filePath == null) {
      // query the data
      Uri pickedUri = data.getExtras().getParcelable(BaseImageTaker.INTENT_RESULT_IMAGE_URI);
      image = getBitmapFromURIviaInputStream(getContentResolver(), pickedUri);

      if (ocrIntent == null) {
        // TODO Add class for this intent
        ocrIntent = new Intent(this, DisplayReaderActivity.class);
      }
      // Set the data for
      if (position == 0) {
        // For reference image
        ocrIntent.putExtra(BASE_SOURCE_TYPE_EXTRA, URI_TYPE_EXTRA);
        ocrIntent.putExtra(BASE_SOURCE_EXTRA, pickedUri);
      } else if (position == 1) {
        // For other image
        ocrIntent.putExtra(QUERY_SOURCE_TYPE_EXTRA, URI_TYPE_EXTRA);
        ocrIntent.putExtra(QUERY_SOURCE_EXTRA, pickedUri);
      }

    } else {
      // Assign target dimension to read in images
      int targetWidth = TARGET_HEIGHT;
      int targetHeight = TARGET_WIDTH;

      BitmapFactory.Options bmpOptions = new BitmapFactory.Options();
      bmpOptions.inJustDecodeBounds = true;
      BitmapFactory.decodeFile(filePath, bmpOptions);
      int currHeight = bmpOptions.outHeight;
      int currWidth = bmpOptions.outWidth;

      int sampleSize = 1;
      {
        // use either width or height
        if ((currWidth > currHeight))
          sampleSize = Math.round((float) currHeight / (float) targetHeight);
        else sampleSize = Math.round((float) currWidth / (float) targetWidth);
      }

      bmpOptions.inSampleSize = sampleSize;
      bmpOptions.inJustDecodeBounds = false;
      // decode the file with restricted sizee
      image = BitmapFactory.decodeFile(filePath, bmpOptions);
    }

    // Update the adapter and transform builder
    if (image == null) {
      message = "Null image cannot display";
      Log.e(TAG, message);
      return;
    } else {
      // Display the image in the gallery
      mImageAdapter.setImage(image, position);

      // Update the transformation process
      if (position == 0) tranBuilder.setReferenceImage(image);
      else if (position == 1) tranBuilder.setOtherImage(image);
    }
  }