java opencv imdecode returns empty Mat!
Hello everoyone!
I spent 2 days looking for answers on the Internet but no luck still. My problem is imdecode returns an empty Mat and I'm not sure what is the problem. Below is my code and the debug output:
Byte data[] = ...;
...
Mat compressed_frame = new Mat(1, size, CvType.CV_8UC1);
compressed_frame.put(0, 0, data);
Mat frame = new Mat();
Mat frame1 = new Mat();
frame = Imgcodecs.imdecode(new MatOfByte(data), Imgcodecs.CV_LOAD_IMAGE_COLOR).clone();
frame1 = Imgcodecs.imdecode(compressed_frame, Imgcodecs.CV_LOAD_IMAGE_COLOR).clone();
System.out.println(compressed_frame);
System.out.println(frame);
System.out.println(frame1);
OUTPUTS of println:
Mat [ 1*72643*CV_8UC1, isCont=true, isSubmat=false, nativeObj=0x225551d0, dataAddr=0x225fd6e0 ]
Mat [ 0*0*CV_8UC1, isCont=true, isSubmat=false, nativeObj=0x225550f0, dataAddr=0x0 ]
Mat [ 0*0*CV_8UC1, isCont=true, isSubmat=false, nativeObj=0x22555940, dataAddr=0x0 ]
I tried both methods I could find to decode the compressed_frame but none works. Please help! BTW I use Opencv 3.2.0!
what is inside "data" ? maybe that's not a valid image ? how do you acquire it ?