Android decodeYUV420SP results in green images?

前端 未结 2 1669
旧巷少年郎
旧巷少年郎 2021-01-21 11:30

Ok so my question is pretty much identical to this: Converting preview frame to bitmap

However his answer is no good, and trying to use it doesn\'t solve my problem.

相关标签:
2条回答
  • 2021-01-21 12:04

    Ok so the problem was the decodeYUV method which I got from a different stackoverflow post here: Converting YUV->RGB(Image processing)->YUV during onPreviewFrame in android? didn't quite work.

    But I replaced that with what I think must be the original decodeYUV method from here: http://code.google.com/p/android/issues/detail?id=823 an

    0 讨论(0)
  • 2021-01-21 12:24

    The key point here is that there are a (large) number of different YUV encodings, and an even larger list of names used for them. A lot of information about all the different variants (and their names) is given by fourcc, although 420SP isn't mentionned explicitly. Looking here, it looks like:

    • 420P is the same as YV12. 'P' appears to stand for planar: there are three 'planes' of data one after the other: Y, U and then V. (Or, in YV21, which is also a 420P encoding, Y, V and then U.)
    • 420SP is the same as NV12 (which is the same as NV21 but with U and V swapped around). 'SP' appears to stand for 'semi-planar', and so '420SP' could, technically, refer to either NV21 or NV12.

    In this case, therefore, you are decoding NV12 (as opposed to NV21) and so the order of U and V is swapped around compared to the answer you quote in your answer. In case it helps, I have provided some code here.

    0 讨论(0)
提交回复
热议问题