Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Mat object returns invalid results.

i have tow android devices the first is asus transformer tf101 and the other is Samsung galaxy note

now, my problem is in generating images from android camera preview. this is my java code:

public void onPreviewFrame(byte[] data, Camera camera) {
    File test = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "/myImg.jpg");

    Mat mYuv = new Mat(previewSize.height + (previewSize.height / 2), previewSize.width, CvType.CV_8UC1);
    Mat mRgba = new Mat(previewSize.height, previewSize.width, CvType.CV_8UC1);
    mYuv.put(0, 0, data);
    Imgproc.cvtColor(mYuv, mRgba, Imgproc.COLOR_YUV2BGR_NV12);
    Highgui.imwrite(test.getPath(), mRgba);
}

on galaxy: mRgba returns fine image, but on transformer the result is green image:

image description

what should i do to generate valid image on transformer??

if my question is not clear please comment me

Mat object returns invalid results.

i have tow android devices the first is asus transformer tf101 and the other is Samsung galaxy note

now, my problem is in generating images from android camera preview. this is my java code:

public void onPreviewFrame(byte[] data, Camera camera) {
    File test = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "/myImg.jpg");

    Mat mYuv = new Mat(previewSize.height + (previewSize.height / 2), previewSize.width, CvType.CV_8UC1);
    Mat mRgba = new Mat(previewSize.height, previewSize.width, CvType.CV_8UC1);
    mYuv.put(0, 0, data);
    Imgproc.cvtColor(mYuv, mRgba, Imgproc.COLOR_YUV2BGR_NV12);
    Highgui.imwrite(test.getPath(), mRgba);
}

on galaxy: mRgba returns fine image, but on transformer the result is green image:

image descriptionimage description

what should i do to generate valid image on transformer??

if my question is not clear please comment me