Unable to save proper Image grabbed from Camera of Evo V 4G

asked 2013-06-18 09:08:07 -0500

I'm trying to get 3D image using Evo V 4G. It has 2 cameras and hence I am using HTC Sense to acces both cameras and it is working and I can see the camera preview (in 3D) also. So I'm trying to save bytes data in Mat, but upon saving, I'm getting following output.

img = new Mat(height, width, CvType.CV_8UC1);
gray = new Mat(height, width, CvType.CV_8UC3); // 3 channel image named 'gray'.
img.put(0, 0, data);
Imgproc.cvtColor(img, gray, Imgproc.COLOR_YUV420sp2RGB);

File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
String filename = "evodispimg2.jpg";
File file = new File(path, filename);
Boolean bool = null;
filename = file.toString();
bool = Highgui.imwrite(filename, decodeimg);

height and width are taken from surface size.

I'm getting the following Image. image description

And when I try this,

decodeimg = new Mat(height, width, CvType.CV_8UC3);
decodeimg = Highgui.imdecode(gray, 1);

And try to save the image, I'm getting a NULL image. imdecode is returning Mat of 0, 0 size. What could be the problem?

How can I properly convert image between colorspaces?

edit retag flag offensive close merge delete