How to convert captured RGB image in Android to greyscale and downscale?

asked 2014-02-27 19:23:05 -0600

habisravi gravatar image

updated 2014-02-28 00:30:41 -0600

berak gravatar image

I want to down scale the captured image to 640x320 , convert it to greyscale and save it to sdcard. Do i need to work with byte[] data for conversion. I want to use the final output image for image matching. Here is my CameraVIew class

public class CameraView extends JavaCameraView implements PictureCallback {private static final String TAG = "CameraView";
private String mPictureFileName;

public CameraView(Context context) {
    super(context, 0);
}

public void takePicture(final String fileName) {
    Log.i(TAG, "Taking picture");
    this.mPictureFileName = fileName;

      mCamera.setPreviewCallback(null);


    mCamera.takePicture(null, null, this);
}

@Override
public void onPictureTaken(byte[] data, Camera camera) {
    Log.i(TAG, "Saving a bitmap to file");

    mCamera.startPreview();
    mCamera.setPreviewCallback(this);


    try {
        FileOutputStream fos = new FileOutputStream(mPictureFileName);

        fos.write(data);
        fos.close();

    } catch (java.io.IOException e) {
        Log.e(TAG, "Exception in photoCallback", e);
    }

}

}

edit retag flag offensive close merge delete