serratus/quaggaJS

Cannot set property 'strokeStyle' of null with not minified /Dist/ file

ragulin72 opened this issue · 1 comments

Hi,
Im trying to make the debug option work. There for I have changed my quagga file from the minified version to the quagga.js version from over here:
https://github.com/serratus/quaggaJS/tree/master/dist
With the minified version, everything worked well.

With the nonminified version, the console starts writing out some configuration settings and then errors about :
Cannot set property 'strokeStyle' of null .

A screen of console over here:
https://imgur.com/jeviZPh

Even when I dont use the minified file (what causes this problem), I minify the code before I try it, so it is minified by Grunt uglify task.

My configuration:

    Quagga.init({
        inputStream: {
            name: "Live",
            type: "LiveStream",
            constraints: {
                width: {ideal: 4096},
                height: {ideal: 2160},
                facingMode: "environment",
                aspectRatio: {min: 1, max: 2}
            },
            area: {
                top: "40%",
                right: "20%",
                left: "20%",
                bottom: "40%"

            }

        },
        // frequency: 2,
        decoder: {
            readers: ["code_128_reader"],
            // debug: {
            //     // drawBoundingBox: true,
            //     showFrequency: true,
            //     // drawScanline: true,
            //     // showPattern: true
            // },
            // multiple: true,
        },
        locate: false,
        numOfWorkers: self.navigator.hardwareConcurrency,
        locator: {
            patchSize: "x-small",
            debug: {
                showCanvas: true,
            }
        }

    }, function (err) {
        if (err) {
            console.log(err);
            return
        }
        $(".controls").on("click", "button.stop", function (e) {
            e.preventDefault();
            Quagga.stop();
        });
        Quagga.start();

        Quagga.onProcessed(function (result) {
            var drawingCtx = Quagga.canvas.ctx.overlay,
                drawingCanvas = Quagga.canvas.dom.overlay;

            if (result) {
                if (result.boxes) {
                    drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute("width")), parseInt(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.codeResult && result.codeResult.code) {
                    Quagga.ImageDebug.drawPath(result.line, {x: 'x', y: 'y'}, drawingCtx, {color: 'red', lineWidth: 3});
                }
            }
        });
        Quagga.onDetected(function (result) {
            var code = result.codeResult.code;
            if (Quagga.lastResult !== code) {
                Quagga.lastResult = code
                var audio = new Audio("../files/barcode-beep_1.mp3")
                audio.play()
                var $node = null, canvas = Quagga.canvas.dom.image;
                // navigator.vibrate(300);
                document.getElementById("frm-searchForm-op").value = code;
                document.getElementById('frm-searchForm-op-label').classList.add('active')

            }
        });
    })

I am sorry. This issue is already solved in #103 . All you have to do is turn off the numOfWorkers in configuration, then it works.