tesseract处理后无法获取原始彩色位图-android

tesseract处理后无法获取原始彩色位图-android,android,bitmap,rgb,tesseract,grayscale,Android,Bitmap,Rgb,Tesseract,Grayscale,我使用android的tesseract库从图像中捕获特定文本。我知道捕获的图像不会保存在任何地方,它会被回收。我需要找到原始的彩色位图。我一直试图找到原始彩色位图,但我只能找到灰度位图: Bitmap bitmap = activity.getCameraManager().buildLuminanceSource(data, width, height).renderCroppedGreyscaleBitmap(); 当我将此位图保存到SD卡时,会得到一个灰度图像。RenderCroppe

我使用android的tesseract库从图像中捕获特定文本。我知道捕获的图像不会保存在任何地方,它会被回收。我需要找到原始的彩色位图。我一直试图找到原始彩色位图,但我只能找到灰度位图:

Bitmap bitmap = activity.getCameraManager().buildLuminanceSource(data, width, height).renderCroppedGreyscaleBitmap();
当我将此位图保存到SD卡时,会得到一个灰度图像。RenderCroppedGreyScaleBamimp()方法如下所示:

public Bitmap renderCroppedGreyscaleBitmap() {
    int width = getWidth();
    int height = getHeight();
    int[] pixels = new int[width * height];
    byte[] yuv = yuvData;
    int inputOffset = top * dataWidth + left;

    for (int y = 0; y < height; y++) {
      int outputOffset = y * width;
      for (int x = 0; x < width; x++) {
        int grey = yuv[inputOffset + x] & 0xff;
        pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
      }
      inputOffset += dataWidth;
    }

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
    return bitmap;
  }
public位图renderCroppedGreyscaleBitmap(){
int width=getWidth();
int height=getHeight();
int[]像素=新int[宽度*高度];
字节[]yuv=yuvData;
int inputOffset=top*dataWidth+left;
对于(int y=0;y

如果有人能告诉我拍摄原始彩色图像,我将不胜感激。我是否必须更改此方法才能获得彩色图像(RGB)?

您是否找到解决此问题的方法?YuvImage YuvImage=new YuvImage(数据,ImageFormat.NV21,宽度,高度,空值);ByteArrayOutputStream bas=新的ByteArrayOutputStream();压缩到JPEG(新的矩形(0,0,宽度,高度),80,baos);字节[]byteArray=baos.toByteArray();位图bitmaptest=BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);你需要写一个问题。首先,我建议你们阅读教程来提问!
    /**
     * YUV to bitmap
     * @param data   The YUV preview frame.
     * @param width  The width of the preview frame.
     * @param height The height of the preview frame.
     * @return
     */
    public static Bitmap byteArray2Bitmap(byte[] data, int width, int height) {
        YuvImage yuvimage = new YuvImage(data, ImageFormat.NV21, width, height, null);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        yuvimage.compressToJpeg(new Rect(0, 0, width, height), 100, baos);
        byte[] rawImage = baos.toByteArray();

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.RGB_565;
        Bitmap bitmap = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length, options);

        Matrix matrix = new Matrix();
        matrix.postRotate(90);
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    }