public static boolean barcodeIsInsideScannerSquare(Barcode barcode) {
    // When the savedSquareFrame or mCameraSize is not initialized yet, which means the layout is
    // not drawn, return false.
    if (mSavedSquareFrame == null || mCameraSize == null) {
      return false;
    }

    Rect barcodeFrameCamera = barcode.getBoundingBox();
    int left = barcodeFrameCamera.left;
    int top = barcodeFrameCamera.top;
    int right = barcodeFrameCamera.right;
    int bottom = barcodeFrameCamera.bottom;

    int cameraWidth = mCameraSize.getWidth();
    int cameraHeight = mCameraSize.getHeight();

    // Convert to canvas' coordinates
    Rect barcodeFrameCanvas = new Rect(
        left * mCanvasWidth / cameraWidth,
        top * mCanvasHeight / cameraHeight,
        right * mCanvasWidth / cameraWidth,
        bottom * mCanvasHeight / cameraHeight);

    return mSavedSquareFrame.contains(barcodeFrameCanvas);
  }
Checking if the barcode is inside the scanner square or not. As the found barcode's dimensions
is in camera's coordinates, we must convert it to canvas' coordinates.
java/com/google/android/apps/authenticator/barcode/BarcodeCentralFilter.java