Git Product home page Git Product logo

Comments (3)

vishalnaikawadi avatar vishalnaikawadi commented on September 23, 2024

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.

shaileshe2logy avatar shaileshe2logy commented on September 23, 2024

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.

Will5 avatar Will5 commented on September 23, 2024

A co-worker also showed me this issue on his OnePlus Nord CE device

from code-scanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.