src/lib/QrScannerWorker.js
function scoreBlackWhiteRun(sequence, ratios) {
        const averageSize = sum(sequence) / sum(ratios);
        let error = 0;
        ratios.forEach((ratio, i) => {
            error += Math.pow((sequence[i] - ratio * averageSize), 2);
        });
        return { averageSize, error };
    }
function scoreBlackWhiteRun(sequence, ratios) {
        const averageSize = sum(sequence) / sum(ratios);
        let error = 0;
        ratios.forEach((ratio, i) => {
            error += Math.pow((sequence[i] - ratio * averageSize), 2);
        });
        return { averageSize, error };
    }
function scoreBlackWhiteRun ( sequence , ratios ) { const averageSize = sum ( sequence ) / sum ( ratios ) ; let error = 0 ; ratios . forEach ( ( ratio , i ) => { error += Math . pow ( ( sequence [ i ] - ratio * averageSize ) , 2 ) ; } ) ; return { averageSize , error } ; }
Takes in a black white run and an array of expected ratios. Returns the average size of the run as well as the "error" - that is the amount the run diverges from the expected ratio
Takes in a black white run and an array of expected ratios . Returns the average size of the run as well as the error - that is the amount the run diverges from the expected ratio