Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsupportedImageFormatException #5

Open
gordinmitya opened this issue Apr 8, 2020 · 6 comments
Open

UnsupportedImageFormatException #5

gordinmitya opened this issue Apr 8, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@gordinmitya
Copy link

gordinmitya commented Apr 8, 2020

Yuv format is not supported: Yuv(resource=androidx.camera.core.SettableImageProxy@f251aa8, width=864, height=480, y=Plane(buffer=java.nio.DirectByteBuffer[pos=0 lim=430048 cap=430048], pixelStride=1, rowStride=896), u=Plane(buffer=java.nio.DirectByteBuffer[pos=0 lim=215007 cap=215007], pixelStride=2, rowStride=896), v=Plane(buffer=java.nio.DirectByteBuffer[pos=0 lim=215007 cap=215007], pixelStride=2, rowStride=896))

Hello, can you suggest what is the possible cause for this error?
I noticed strange values width = 864 but rowStride = 896, may be this is the reason.

Sony Xperia XZ3 Black (H9436)

@gordinmitya
Copy link
Author

gordinmitya commented Apr 9, 2020

@sellmair can you provide some info about these lines:

operator fun YuvImage.Factory.invoke(yuv: Yuv): YuvImage {
    // YuvImage.kt
    if (yuv.y.pixelStride != 1 || yuv.y.rowStride != yuv.width) { // <-- here
        throw UnsupportedImageFormatException(yuv)

// Yuv+defrag.kt
fun Yuv.defrag(): Yuv {
    val start = System.currentTimeMillis()

    require(y.pixelStride == 1)
    require(y.rowStride == width) // <--- and here

In documentation it's not stated that y.rowStride == width is always guaranteed.
Why don't we just remove them and let defragPlanePadding do the job?

@m-rm
Copy link

m-rm commented Apr 14, 2020

Thanks for creating the issue, I have exactly the same problem using a Google Pixel 2.

com.quickbirdstudios.yuv2mat.UnsupportedImageFormatException: Yuv format is not supported: Yuv(resource=android.media.ImageReader$SurfaceImage@691a964, width=1440, height=1080, y=Plane(buffer=java.nio.DirectByteBuffer[pos=0 lim=1589728 cap=1589728], pixelStride=1, rowStride=1472), u=Plane(buffer=java.nio.DirectByteBuffer[pos=0 lim=794847 cap=794847], pixelStride=2, rowStride=1472), v=Plane(buffer=java.nio.DirectByteBuffer[pos=0 lim=794847 cap=794847], pixelStride=2, rowStride=1472))
        at com.quickbirdstudios.yuv2mat.YuvImageKt.invoke(YuvImage.kt:121)
        at com.quickbirdstudios.yuv2mat.YuvImageKt.invoke(YuvImage.kt:111)
        at com.quickbirdstudios.yuv2mat.Image_toMatKt.rgb(Image+toMat.kt:20)
        at com.quickbirdstudios.yuv2mat.Yuv$Companion.rgb(Yuv.kt:57)

@gordinmitya
Copy link
Author

gordinmitya commented Apr 14, 2020

@m-rm I fixed it with commenting two lines I mentioned above

But that's not the best fix, because it will move all the pixels from NV21 format to YUV420. I'm going to create more efficient library – will post update here.

@sellmair sellmair self-assigned this Apr 20, 2020
@sellmair sellmair added the bug Something isn't working label Apr 20, 2020
@LiorA1
Copy link

LiorA1 commented Apr 27, 2020

you tried the camera2 API ?

@gordinmitya
Copy link
Author

with camera api 1 we don't need that – there's ready to use byte[]

@gordinmitya
Copy link
Author

gordinmitya commented Sep 24, 2020

@LiorA1 @m-rm
made a correct implementation with unit tests, demo app, benchmarks
https://github.com/gordinmitya/yuv2buf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants