简体   繁体   中英

camera preview gives gray images

i am developing android app using android sdk camera. on camera preview i need the frame content so i am using PreviewCallback to return the data in byte array, now my problem is saving the data in mat object the mat return gray images:

public void onPreviewFrame(byte[] data, Camera camera) {
    Mat src = new Mat(previewSize.height, previewSize.width, CvType.CV_8U, new Scalar(255));
    src.put(0, 0, data);
    Highgui.imwrite("/mnt/sdcard/1.jpg", src);
}

anybody can help me to generate argb images

note: i am using NV21 in preview image format.

Do this instead:

Mat src = new Mat(previewSize.height, previewSize.width, CvType.CV_8UC3);

If it does not work, it means your data is already gray, so you must have set it as gray somewhere in your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM