bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.65k stars 737 forks source link

matrix.cpp:424: error: (-215:Assertion failed) total() == 0 || data != NULL #1282

Open rantianhua opened 1 year ago

rantianhua commented 1 year ago

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 don't understand why the assertion is failed.

saudet commented 1 year ago

That's a bug in the official Java API, please report upstream: https://github.com/opencv/opencv