@Override
  public byte[] getRow(int y, byte[] row) {
    if (y < 0 || y >= getHeight()) {
      throw new IllegalArgumentException("Requested row is outside the image: " + y);
    }
    int width = getWidth();
    if (row == null || row.length < width) {
      row = new byte[width];
    }
    int offset = (y + top) * dataWidth + left;
    System.arraycopy(yuvData, offset, row, 0, width);
    return row;
  }
This object extends LuminanceSource around an array of YUV data returned from the camera driver,
with the option to crop to a rectangle within the full data. This can be used to exclude
superfluous pixels around the perimeter and speed up decoding.

It works for any pixel format where the Y channel is planar and appears first, including
YCbCr_420_SP and YCbCr_422_SP.

The code for this class was adapted from the ZXing project: http://code.google.com/p/zxing
OCRTest/src/main/java/edu/sfsu/cs/orange/ocr/PlanarYUVLuminanceSource.java