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

2.1.1版本在oppo A32机型上识别不了扫码 #181

Closed
itsgm opened this issue Jan 18, 2022 · 10 comments
Closed

2.1.1版本在oppo A32机型上识别不了扫码 #181

itsgm opened this issue Jan 18, 2022 · 10 comments

Comments

@itsgm
Copy link

itsgm commented Jan 18, 2022

2.1.1之前的版本可以识别,整个demo的扫码都无法识别

@itsgm
Copy link
Author

itsgm commented Jan 18, 2022

2.1.1不行,我回退到1.1.9版本用了,难道是camerax的问题么

@yangzyqq
Copy link

这个问题解决了么

@wangxiongxu
Copy link

2.0.3也不行

@mengxn
Copy link

mengxn commented Jul 15, 2022

Realme Q5手机上,2.x都识别不了,回退到1.1.9可以了。

@pp520henni
Copy link

VIVO Y31s 也无法扫描

@qiuxfeng1985
Copy link

qiuxfeng1985 commented Apr 11, 2023

原因:ImageAnalyzer 解析Y数据时出现了异常,在某些手机上,remaining() 方法返回的是字节数组的容量,而不是实际大小

ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] data = new byte[buffer.remaining()];
buffer.get(data);

改为如下方式

int width = image.getWidth();
int height = image.getHeight();
ByteBuffer yBuffer = image.getPlanes()[0].getBuffer();
int numPixels = (int) (width * height * ImageFormat.getBitsPerPixel(ImageFormat.YUV_420_888) / 8);
byte[] data = new byte[numPixels];
int index = 0;
int yRowStride = image.getPlanes()[0].getRowStride();
int yPixelStride = image.getPlanes()[0].getPixelStride();
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
data[index++] = yBuffer.get(y * yRowStride + x * yPixelStride);
}
}

@jenly1314
Copy link
Owner

没有相关机型来进行测试验证;麻烦更新至当前最新版本 2.4.0 试试,看是否还存在此问题?

@qiuxfeng1985
Copy link

在oppo A32上验证没有问题了

@Allen8Lee
Copy link

Allen8Lee commented May 4, 2023 via email

@jenly1314
Copy link
Owner

在oppo A32上验证没有问题了

感谢验证

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants