Comments (3)
So after verifying the issue on the OP NORD 5G, I noticed a few things.
when the size is returned from the Utils.findSuitableImageSize()
set in parameters.setPreviewSize(imageWidth, imageHeight)
causing the issue and throwing the exception (which is ignored) inside a startPreviewInternal()
method.
it is throwing below-mentioned exception:
java.lang.RuntimeException: setParameters failed
parameters.getSupportedPreviewSizes() returns below supported sizes.
h: 2080 w: 4624
h: 2080 w: 4608
h: 1890 w: 4160
h: 1872 w: 4160
h: 2250 w: 4000
h: 1818 w: 4000
h: 1800 w: 4000
h: 2160 w: 3840
h: 1644 w: 3840
h: 2592 w: 3456
h: 2464 w: 3280
h: 2448 w: 3264
h: 1836 w: 3264
h: 1472 w: 3264
h: 2400 w: 3200
h: 1440 w: 3168
h: 2160 w: 2880
h: 1944 w: 2592
h: 1512 w: 2688
h: 1080 w: 2400
h: 1748 w: 2328
h: 1168 w: 2592
h: 1080 w: 2376
h: 1728 w: 2304
h: 1080 w: 2160
h: 1080 w: 1920
h: 864 w: 1920
h: 822 w: 1920
h: 1200 w: 1600
h: 800 w: 1600
h: 720 w: 1600
h: 720 w: 1584
h: 1080 w: 1440
h: 960 w: 1280
h: 768 w: 1280
h: 768 w: 1024
h: 720 w: 1280
h: 540 w: 1188
h: 540 w: 1200
h: 360 w: 840
h: 400 w: 800
h: 360 w: 792
h: 540 w: 720
h: 480 w: 720
h: 480 w: 640
h: 360 w: 640
h: 288 w: 352
h: 240 w: 320
h: 144 w: 176
h: 2250 w: 4000
and findSuitableImageSize()
is returning h: 2250 w: 4000, but for this specific size I'm not able to see the preview, and an exception is being thrown. but if I use this size (h: 2080 w: 4624), it is working fine for me. I don't know the exact reason but I've commented few lines of code and it is working fine on all of the devices I checked.
change
@NonNull
public static Point findSuitableImageSize(@NonNull final Parameters parameters,
final int frameWidth, final int frameHeight) {
final List<Camera.Size> sizes = parameters.getSupportedPreviewSizes();
for(int i = 0; i < sizes.size(); i++) {
Log.d("====size: ", "h: "+ sizes.get(i).height + " w: "+sizes.get(i).width);
}
if (sizes != null && !sizes.isEmpty()) {
Collections.sort(sizes, new CameraSizeComparator());
// final float frameRatio = (float) frameWidth / (float) frameHeight;
for (float distortion = MIN_DISTORTION; distortion <= MAX_DISTORTION;
distortion += DISTORTION_STEP) {
for (final Camera.Size size : sizes) {
final int width = size.width;
final int height = size.height;
// if (width * height >= MIN_PREVIEW_PIXELS &&
// Math.abs(frameRatio - (float) width / (float) height) <= distortion) {
Log.d("====returned size", "h: "+height+" w: "+width);
return new Point(width, height);
// }
}
}
}
final Camera.Size defaultSize = parameters.getPreviewSize();
if (defaultSize == null) {
throw new CodeScannerException("Unable to configure camera preview size");
}
Log.d("====default size", "h: "+defaultSize.height+" w: "+defaultSize.width);
return new Point(defaultSize.width, defaultSize.height);
}
Note: Not all OP NORD 5G devices are facing this issue. some OP 5 devices are also facing the same problem.
from code-scanner.
I am also facing the same issue on my project on the OnePlus Nord CE device. I have used the library using Gradle (v2.3.2).
@vishalnaikawadi Is there any way to fix it without modifying the library code?
from code-scanner.
A co-worker also showed me this issue on his OnePlus Nord CE device
from code-scanner.
Related Issues (20)
- Does the codescanner have a function to take in uri?
- Orientation change issue
- Crash on google play pre-launch & also on production on clients devices
- How to enable and disable flash light with flash icon? HOT 7
- Android 33 Library does not work
- Library is not working HOT 2
- Flash blink while set ScanMode.SINGLE
- Is there any way to speed up?
- How can we add text below frame ? HOT 1
- NFC Functionality Stops Working When QR Code Scanning Preview is Started on Android 13 HOT 1
- Blank screen on xiaomi redmi A2 HOT 6
- Flash not working in Android 11 HOT 3
- QR scan starts lagging HOT 1
- Scan returns wrong data HOT 1
- Lagging when navigate to fragment with CodeScanner
- Camera is dark due to FPSrate
- flash light is not working in some devices HOT 1
- Library not working
- Library not working with most QR codes
- Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=11664; index=11664
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from code-scanner.