Reputation: 1906
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.
Upvotes: 2
Views: 708
Reputation: 8914
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.
Upvotes: 1