[英]Nexus 9 Camera2 API - YUV_420_888 vs. getOutputSizes()
I'm implementing the Camera2 API with the YUV_420_888 format on a Nexus 9. I checked the output sizes and wanted to use the largest (8MP, 3280 x 2460) size to save. 我正在Nexus 9上以YUV_420_888格式实现Camera2 API。我检查了输出尺寸,并希望使用最大尺寸(8MP,3280 x 2460)进行保存。 However, it just appears as static lines, similar to how old TV's looked without a signal.
但是,它只是显示为静态线,类似于没有信号的老式电视机。 I would like to stick with YUV_420_888 since my end goal is to save grayscale data (Y component).
我想坚持使用YUV_420_888,因为我的最终目标是保存灰度数据(Y分量)。
I originally thought it was a camera bandwidth issue, but the same thing happened at some of the small sizes (320 x 240). 我原本以为这是相机带宽问题,但是在某些小尺寸(320 x 240)上也发生了同样的事情。 None of the problems went away even when I increased frame duration and decreased the size of the preview to save on bandwidth.
即使增加帧持续时间并减小预览大小以节省带宽,所有问题都不会消失。 Some of the other sizes DID work (2048 x 1536, 1280 x 720) but I did not check all of them.
其他一些DID尺寸也可以使用(2048 x 1536、1280 x 720),但我没有检查所有尺寸。
I'm starting to think getOutputSizes() may not necessarily be accurate. 我开始认为getOutputSizes()不一定准确。 It gave me the same results for all other formats except RAW_SENSOR (JPEG, YUV_420_888, YV12).
除了RAW_SENSOR(JPEG,YUV_420_888,YV12)以外,其他所有格式的结果都相同。 Has anyone encountered this or determined a solution?
有没有人遇到这个问题或确定解决方案?
Figured out the issue. 找出问题。 I was not taking into account the rowStride of the returned pixels.
我没有考虑返回像素的rowStride。 So I had to run a for-loop to extract the non-padded data before saving it:
所以我必须运行一个for循环来提取未填充的数据,然后再保存它:
myRowStride = mImage.getPlanes()[0].getRowStride();
int iSkippedBytes = 0;
for (int i = 0; i < mStillSize.getWidth() * mStillSize.getHeight(); i++){
if (i % mStillSize.getWidth() == 0 && i != 0)
iSkippedBytes = iSkippedBytes + (myRowStride - mStillSize.getWidth());
imageBytes[i] = bytes[i + iSkippedBytes];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.