I had a yuv i420 frame, height is 620, width is 1472, I used the following code to convert the binary data to Mat:
val data = FileInputStream(File("/Users/user/Downloads/one_frame.yuv")).readBytes()
val buf = ByteBuffer.wrap(data)
val yuvMat = Mat(620 + 620 / 2 , 1472, CvType.CV_8UC1, buf)
But I encountered the error:
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.6.0) /Users/runner/work/javacpp-presets/javacpp-presets/opencv/cppbuild/macosx-arm64/opencv-4.6.0/modules/core/src/matrix.cpp:424: error: (-215:Assertion failed) total() == 0 || data != NULL in function 'Mat'
]
at org.opencv.core.Mat.n_Mat(Native Method)
at org.opencv.core.Mat.<init>(Mat.java:41)
I had a yuv i420 frame, height is 620, width is 1472, I used the following code to convert the binary data to Mat:
But I encountered the error:
I don't understand why the assertion is failed.