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

Image Not Detected #119

Open
cinnamolly opened this issue Jul 15, 2016 · 8 comments
Open

Image Not Detected #119

cinnamolly opened this issue Jul 15, 2016 · 8 comments
Labels

Comments

@cinnamolly
Copy link

Hi,

I'm finding that static images with clear barcodes (even barcodes generated from the Internet) are either resulting in "not detected" or the error:
if(result.codeResult) { ^ TypeError: Cannot read property 'codeResult' of undefined

Is there a certain type or resolution of image that needs to be uploaded? Why does this happen to my static images, but not the test images?

Any help would be greatly appreciated.

Thank you,
Molly

@cinnamolly
Copy link
Author

cinnamolly commented Jul 15, 2016

For example, this image
bar2
returned the error I pasted above. Attached additionally is my node source code as a txt file.
bar.txt

@sidonaldson
Copy link

I have found this too. It would appear that if it doesn't find a barcode it returns the callback without a result argument.

On line:4398 of lib/quagga.js I added it to return a empty object if result was null

           this.init(config, function () {
                _events2.default.once("processed", function (result) {
                    _this.stop();
                    resultCallback.call(null, result || {});
                }, true);
                _start();
            });

@ericblade
Copy link
Collaborator

I feel like having onDetected called without a result is some kind of a bug. Anyone else?

@ericblade ericblade added the bug label Jun 8, 2018
@TomasHubelbauer
Copy link
Collaborator

I agree with this not being a good experience, I also think it happened to me before. Definitely something we should try to track down and prevent.

@ericblade
Copy link
Collaborator

While getting testing working standalone with #303, I noticed that the callback is called pretty frequently without the expected code data. The question I guess I have, is are my expectations incorrect, or is that an incorrect response? decodeSingle() probably should callback with something. However, there seems to be an expectation throughout the code base that result codes will always be available to the callback ..

@TomasHubelbauer
Copy link
Collaborator

I'll need to take a closer look at the internal structure to understand how we could improve this, but as far as expectations go, I think the current design could be improved.

@ericblade
Copy link
Collaborator

ericblade commented Jun 11, 2018

What I see in src/quagga.js in the area of line 534 is

        this.init(config, () => {
            Events.once("processed", (result) => {
                this.stop();
                resultCallback.call(null, result);
            }, true);
            start();
        });

.... and here-in lies the specific problem:

decodeSingle's callback is not called similarly to onDetected -- it is called similarly to onProcessed.

In src/quagga.js publishResult()

function publishResult(result, imageData) {
    let resultToPublish = result;

    if (result && _onUIThread) {
        transformResult(result);
        addResult(result, imageData);
        resultToPublish = result.barcodes || result;
    }

    Events.publish("processed", resultToPublish);
    if (hasCodeResult(result)) {
        Events.publish("detected", resultToPublish);
    }
}

So, decodeSingle calls resultCallback as if it were onProcessed, but existing code (including at least the tests, and probably the samples, and the README, but i haven't looked yet) is expecting it to be called as if it were onDetected.

I think this could cause quite a few questions.

If nothing else, then there's definitely an action to be taken: clean up all uses of decodeSingle in samples/tests/documentation, to understand what to do in the case of no result.codeResult.

@ericblade
Copy link
Collaborator

Also, in my first comment on this thread, i had said onDetected, without reading the code file. The people reporting this problem have been using decodeSingle(). I'm pretty sure that in live mode, I've never seen onDetected called without a result, even if it isn't an accurate result.

SO @cinnamolly and @sidonaldson if you're still out here, the root of the problem is expecting decodeSingle() to always return a codeResult -- if it wasn't able to decode a barcode, then you get no codeResult.

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

No branches or pull requests

4 participants