Ask Your Question
0

Mat object returns invalid results.

asked 2013-01-18 10:14:52 -0600

MoHaKa gravatar image

updated 2013-01-18 10:19:04 -0600

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-01-18 13:24:40 -0600

It looks like a problem with resolution. Frame from camera is smaller that application expects or frame data has format, that is differ from YUV420sp. Firstly, check is frame resolution is the same as you expect.

edit flag offensive delete link more

Comments

in galaxy the resolution is 960 720 but on transformer 704 576 Is this the correct resolution to get valid image??

MoHaKa gravatar imageMoHaKa ( 2013-01-18 17:15:44 -0600 )edit

Question Tools

Stats

Asked: 2013-01-18 10:14:52 -0600

Seen: 471 times

Last updated: Jan 18 '13