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

No results from the scanner on > iOS 14 #486

Open
malte94 opened this issue Jul 13, 2022 · 16 comments
Open

No results from the scanner on > iOS 14 #486

malte94 opened this issue Jul 13, 2022 · 16 comments

Comments

@malte94
Copy link

malte94 commented Jul 13, 2022

The scanning functionality of Quagga stopped working. I tried different aspectRatios and different configurations regarding the camera selection without any success.

The camera selection, on the other hand, and general implementation work fine – the stream starts without any issues. No barcodes (ean_code) are recognized though.

Android works without any issues.

 const QuaggaInit = () => {
        Quagga.init(
            {
                inputStream: {
                    type: "LiveStream",
                    constraints: {
                        width: {
                            min: 450
                        },
                        height: {
                            min: 300
                        },
                        deviceId: selectedDevice ? selectedDevice : "default",
                        facingMode: "environment",
                        /*aspectRatio: {
                            "min": 1,
                            "max": 2
                        }*/
                    }
                },
                locator: {
                    "patchSize": "medium",
                    "halfSample": true
                },
                numOfWorkers: 2,
                frequency: 10,
                decoder: {
                    readers: [
                        "ean_reader",
                    ]
                },
                locate: true
            }, err => {
                if (err) {
                    console.log(err, "error msg");
                }
                Quagga.start();
                return () => {
                    Quagga.stop()
                }
            });
    }

    React.useEffect(() => {
        getDevices();
        checkPermissions();
        Quagga.onProcessed(result => {
            var drawingCtx = Quagga.canvas.ctx.overlay,
                drawingCanvas = Quagga.canvas.dom.overlay;

            if (result) {
                if (result.boxes) {
                    drawingCtx.clearRect(
                        0,
                        0,
                        Number(drawingCanvas.getAttribute("width")),
                        Number(drawingCanvas.getAttribute("height"))
                    );
                    result.boxes
                        .filter(function (box) {
                            return box !== result.box;
                        })
                        .forEach(function (box) {
                            Quagga.ImageDebug.drawPath(box, { x: 0, y: 1 }, drawingCtx, {
                                color: "green",
                                lineWidth: 2
                            });
                        });
                }

                if (result.box) {
                    Quagga.ImageDebug.drawPath(result.box, { x: 0, y: 1 }, drawingCtx, {
                        color: "#00F",
                        lineWidth: 2
                    });
                }

                if (result.codeResult && result.codeResult.code) {
                    Quagga.ImageDebug.drawPath(
                        result.line,
                        { x: "x", y: "y" },
                        drawingCtx,
                        { color: "red", lineWidth: 3 }
                    );
                }
            }
        });

        Quagga.onDetected(detected);

    }, []);

    const detected = result => {
        onDetected(result.codeResult.code);
    };

Test device: iPhone 12 Pro

@ericblade
Copy link
Collaborator

ericblade commented Jul 15, 2022

I'm told that selecting an aspectRatio: { ideal: 1 } in your constraint works there, although I can't confirm that since I lack any iOS devices.

@malte94
Copy link
Author

malte94 commented Jul 15, 2022

Thank you @ericblade
Unfortunately, that won't fix the issue (anymore).

@ericblade
Copy link
Collaborator

just realized it's aspectRatio: { ideal: 1 } ..

might take a look through this thread for some ideas ericblade/quagga2#419

@malte94
Copy link
Author

malte94 commented Jul 22, 2022

@ericblade

Thank you. I tried this configuration. Still not working properly.

The iPhone camera appears to be incredibly picky. I scanned one EAN code succesfully, which had nearly the exact camera format. As soon as some text is around the EAN, or the EAN is quite small and can not be recorded in the camera's format due to exceeding the minimum focus distance of the iPhone's camera, the scanner always fails.

On the other hand, Android scans EANs without any problems, even if they are not in the camera format, surrounded by text or very small.

So would you suppose that this is an issue related to the library (The iPhone camera itself works perfectly, focusses correctly) or due to Safari/iOS?

@ericblade
Copy link
Collaborator

I wish I had any more insight to that. The control that a web app has, and more so on iOS, compared to a native app, over the camera functionality is pretty minimal. It could be hardware, it could be OS/Browser, or it c ould be the library. Could be a combination of all of that just not working together in expected ways that work elsewhere. :|

@JonSnow-vn
Copy link

does you fixed it? i have same issues, this beacause onProcessed() function run only one time when init. So it never get onDetected()

@malte94
Copy link
Author

malte94 commented Aug 16, 2022

@JonSnow-vn
Nope, but Android works fine. onDetected() is called correctly each time on detection :)

@JonSnow-vn
Copy link

@JonSnow-vn Nope, but Android works fine. onDetected() is called correctly each time on detection :)

yes, me too, this problem only on iphone. Like what i say, on iphone, onProcessed() function run only one time when init. I test on macbook pro and ipad pro its work fine. I don't konw ipad mini is work? i dont have this.

@malte94
Copy link
Author

malte94 commented Aug 16, 2022

Interesting observation, I have not debugged it that in-depth.

@JonSnow-vn
Copy link

I wish I had any more insight to that. The control that a web app has, and more so on iOS, compared to a native app, over the camera functionality is pretty minimal. It could be hardware, it could be OS/Browser, or it c ould be the library. Could be a combination of all of that just not working together in expected ways that work elsewhere. :|

you have any idea?

@ericblade
Copy link
Collaborator

Unfortunately, I don't. The one person using my app on iOS isn't reporting any problems.

@fabricyo
Copy link

Unfortunately, I don't. The one person using my app on iOS isn't reporting any problems.

I can confirm, is working fine here.

@erikmillergalow
Copy link

Anyone have any other ideas to resolve this? I'm still unable to scan on my iPhone 13 mini after messing around with setting aspectRatio.

@PriyaN-d
Copy link

PriyaN-d commented Aug 1, 2024

Is this issue resolved?

@erikmillergalow
Copy link

@PriyaN-d Yes, we were able to get this working again last year - though we did have to add a way for users to try out each available camera themselves (different models expose different settings/lenses, front/back/wide angle etc...)

@ericblade
Copy link
Collaborator

though we did have to add a way for users to try out each available camera themselves (different models expose different settings/lenses, front/back/wide angle etc...)

this is probably the way. On a lot of Android devices, the default camera selection provides fisheye view, which mangles the image

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

6 participants