简体   繁体   English

Nexus 9 Camera2 API-YUV_420_888与getOutputSizes()

[英]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.

相关问题 Android Camera2 API YUV_420_888 转 JPEG - Android Camera2 API YUV_420_888 to JPEG 将 Android camera2 api YUV_420_888 转换为 RGB - Convert Android camera2 api YUV_420_888 to RGB Android Camera2 YUV_420_888 Y频道解读 - Android Camera2 YUV_420_888 Y Channel Interpretation 使用新的Android camera2 api从YUV_420_888进行JPEG编码时的绿色图像 - Green images when doing a JPEG encoding from YUV_420_888 using the new Android camera2 api Android camera2 createCaptureRequest在获取YUV_420_888图像时返回所有黑色像素 - Android camera2 createCaptureRequest returns all black pixels when getting YUV_420_888 image camera2 捕获的图片 - 从 YUV_420_888 到 NV21 的转换 - camera2 captured picture - conversion from YUV_420_888 to NV21 camera2如何从图像阅读器监听器中的YUV_420_888图像中获取Exif数据 - camera2 How to get Exif data from YUV_420_888 image in image reader listener Android camera2下将YUV_420_888转换为位图的错误图像 - Incorrect image converting YUV_420_888 into Bitmaps under Android camera2 Android camera2 输出到 ImageReader 格式 YUV_420_888 仍然很慢 - Android camera2 output to ImageReader format YUV_420_888 still slow YUV_420_888解读三星Galaxy S7(相机2) - YUV_420_888 interpretation on Samsung Galaxy S7 (Camera2)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM