Socket
Socket
Sign inDemoInstall

@zxing/library

Package Overview
Dependencies
2
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.17.0 to 0.17.1

6

esm/browser/BrowserCodeReader.js

@@ -616,3 +616,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

// trying again
return setTimeout(() => loop(resolve, reject), this._timeBetweenDecodingAttempts);
return setTimeout(loop, this._timeBetweenDecodingAttempts, resolve, reject);
}

@@ -637,3 +637,3 @@ reject(e);

callbackFn(result, null);
setTimeout(() => loop(), this.timeBetweenScansMillis);
setTimeout(loop, this.timeBetweenScansMillis);
}

@@ -646,3 +646,3 @@ catch (e) {

// trying again
setTimeout(() => loop(), this._timeBetweenDecodingAttempts);
setTimeout(loop, this._timeBetweenDecodingAttempts);
}

@@ -649,0 +649,0 @@ }

@@ -71,3 +71,3 @@ import InvertedLuminanceSource from '../core/InvertedLuminanceSource';

crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
this.crop(left, top, width, height);
super.crop(left, top, width, height);
return this;

@@ -74,0 +74,0 @@ }

@@ -20,18 +20,21 @@ import BitMatrix from '../../common/BitMatrix';

detect(): DetectorResult;
private static shiftPoint;
private static moveAway;
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a rectangular matrix
* Detect a solid side which has minimum transition.
*/
private correctTopRightRectangular;
private detectSolid1;
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a square matrix
* Detect a second solid side next to first solid side.
*/
private detectSolid2;
/**
* Calculates the corner position of the white top right module.
*/
private correctTopRight;
private isValid;
private static distance;
/**
* Increments the Integer associated with a key by one.
* Shift the edge points to the module center.
*/
private static increment;
private shiftToModuleCenter;
private isValid;
private static sampleGrid;

@@ -38,0 +41,0 @@ /**

import ResultPoint from '../../ResultPoint';
import DetectorResult from '../../common/DetectorResult';
import GridSamplerInstance from '../../common/GridSamplerInstance';
import MathUtils from '../../common/detector/MathUtils';
import WhiteRectangleDetector from '../../common/detector/WhiteRectangleDetector';

@@ -31,3 +30,3 @@ import NotFoundException from '../../NotFoundException';

this.image = image;
this.rectangleDetector = new WhiteRectangleDetector(image);
this.rectangleDetector = new WhiteRectangleDetector(this.image);
}

@@ -42,191 +41,212 @@ /**

const cornerPoints = this.rectangleDetector.detect();
const pointA = cornerPoints[0];
const pointB = cornerPoints[1];
const pointC = cornerPoints[2];
const pointD = cornerPoints[3];
// Point A and D are across the diagonal from one another,
// as are B and C. Figure out which are the solid black lines
// by counting transitions
const transitions = [];
transitions.push(this.transitionsBetween(pointA, pointB));
transitions.push(this.transitionsBetween(pointA, pointC));
transitions.push(this.transitionsBetween(pointB, pointD));
transitions.push(this.transitionsBetween(pointC, pointD));
transitions.sort(ResultPointsAndTransitions.resultPointsAndTransitionsComparator);
// Sort by number of transitions. First two will be the two solid sides; last two
// will be the two alternating black/white sides
const lSideOne = transitions[0];
const lSideTwo = transitions[1];
// Figure out which point is their intersection by tallying up the number of times we see the
// endpoints in the four endpoints. One will show up twice.
const pointCount = new Map();
Detector.increment(pointCount, lSideOne.getFrom());
Detector.increment(pointCount, lSideOne.getTo());
Detector.increment(pointCount, lSideTwo.getFrom());
Detector.increment(pointCount, lSideTwo.getTo());
let maybeTopLeft = null;
let bottomLeft = null;
let maybeBottomRight = null;
for (let [point, value] of Array.from(pointCount.entries())) {
if (value === 2) {
bottomLeft = point; // this is definitely the bottom left, then -- end of two L sides
}
else {
// Otherwise it's either top left or bottom right -- just assign the two arbitrarily now
if (maybeTopLeft == null) {
maybeTopLeft = point;
}
else {
maybeBottomRight = point;
}
}
}
if (maybeTopLeft == null || bottomLeft == null || maybeBottomRight == null) {
let points = this.detectSolid1(cornerPoints);
points = this.detectSolid2(points);
points[3] = this.correctTopRight(points);
if (!points[3]) {
throw new NotFoundException();
}
// Bottom left is correct but top left and bottom right might be switched
const corners = [maybeTopLeft, bottomLeft, maybeBottomRight];
// Use the dot product trick to sort them out
ResultPoint.orderBestPatterns(corners);
// Now we know which is which:
const bottomRight = corners[0];
bottomLeft = corners[1];
const topLeft = corners[2];
// Which point didn't we find in relation to the "L" sides? that's the top right corner
let topRight;
if (!pointCount.has(pointA)) {
topRight = pointA;
points = this.shiftToModuleCenter(points);
const topLeft = points[0];
const bottomLeft = points[1];
const bottomRight = points[2];
const topRight = points[3];
let dimensionTop = this.transitionsBetween(topLeft, topRight) + 1;
let dimensionRight = this.transitionsBetween(bottomRight, topRight) + 1;
if ((dimensionTop & 0x01) === 1) {
dimensionTop += 1;
}
else if (!pointCount.has(pointB)) {
topRight = pointB;
if ((dimensionRight & 0x01) === 1) {
dimensionRight += 1;
}
else if (!pointCount.has(pointC)) {
topRight = pointC;
if (4 * dimensionTop < 7 * dimensionRight && 4 * dimensionRight < 7 * dimensionTop) {
// The matrix is square
dimensionTop = dimensionRight = Math.max(dimensionTop, dimensionRight);
}
let bits = Detector.sampleGrid(this.image, topLeft, bottomLeft, bottomRight, topRight, dimensionTop, dimensionRight);
return new DetectorResult(bits, [topLeft, bottomLeft, bottomRight, topRight]);
}
static shiftPoint(point, to, div) {
let x = (to.getX() - point.getX()) / (div + 1);
let y = (to.getY() - point.getY()) / (div + 1);
return new ResultPoint(point.getX() + x, point.getY() + y);
}
static moveAway(point, fromX, fromY) {
let x = point.getX();
let y = point.getY();
if (x < fromX) {
x -= 1;
}
else {
topRight = pointD;
x += 1;
}
// Next determine the dimension by tracing along the top or right side and counting black/white
// transitions. Since we start inside a black module, we should see a number of transitions
// equal to 1 less than the code dimension. Well, actually 2 less, because we are going to
// end on a black module:
// The top right point is actually the corner of a module, which is one of the two black modules
// adjacent to the white module at the top right. Tracing to that corner from either the top left
// or bottom right should work here.
let dimensionTop = this.transitionsBetween(topLeft, topRight).getTransitions();
let dimensionRight = this.transitionsBetween(bottomRight, topRight).getTransitions();
if ((dimensionTop & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionTop++;
if (y < fromY) {
y -= 1;
}
dimensionTop += 2;
if ((dimensionRight & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionRight++;
else {
y += 1;
}
dimensionRight += 2;
let bits;
let correctedTopRight;
// Rectangular symbols are 6x16, 6x28, 10x24, 10x32, 14x32, or 14x44. If one dimension is more
// than twice the other, it's certainly rectangular, but to cut a bit more slack we accept it as
// rectangular if the bigger side is at least 7/4 times the other:
if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) {
// The matrix is rectangular
correctedTopRight =
this.correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight);
if (correctedTopRight == null) {
correctedTopRight = topRight;
}
dimensionTop = this.transitionsBetween(topLeft, correctedTopRight).getTransitions();
dimensionRight = this.transitionsBetween(bottomRight, correctedTopRight).getTransitions();
if ((dimensionTop & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionTop++;
}
if ((dimensionRight & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionRight++;
}
bits = Detector.sampleGrid(this.image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionTop, dimensionRight);
return new ResultPoint(x, y);
}
/**
* Detect a solid side which has minimum transition.
*/
detectSolid1(cornerPoints) {
// 0 2
// 1 3
let pointA = cornerPoints[0];
let pointB = cornerPoints[1];
let pointC = cornerPoints[3];
let pointD = cornerPoints[2];
let trAB = this.transitionsBetween(pointA, pointB);
let trBC = this.transitionsBetween(pointB, pointC);
let trCD = this.transitionsBetween(pointC, pointD);
let trDA = this.transitionsBetween(pointD, pointA);
// 0..3
// : :
// 1--2
let min = trAB;
let points = [pointD, pointA, pointB, pointC];
if (min > trBC) {
min = trBC;
points[0] = pointA;
points[1] = pointB;
points[2] = pointC;
points[3] = pointD;
}
if (min > trCD) {
min = trCD;
points[0] = pointB;
points[1] = pointC;
points[2] = pointD;
points[3] = pointA;
}
if (min > trDA) {
points[0] = pointC;
points[1] = pointD;
points[2] = pointA;
points[3] = pointB;
}
return points;
}
/**
* Detect a second solid side next to first solid side.
*/
detectSolid2(points) {
// A..D
// : :
// B--C
let pointA = points[0];
let pointB = points[1];
let pointC = points[2];
let pointD = points[3];
// Transition detection on the edge is not stable.
// To safely detect, shift the points to the module center.
let tr = this.transitionsBetween(pointA, pointD);
let pointBs = Detector.shiftPoint(pointB, pointC, (tr + 1) * 4);
let pointCs = Detector.shiftPoint(pointC, pointB, (tr + 1) * 4);
let trBA = this.transitionsBetween(pointBs, pointA);
let trCD = this.transitionsBetween(pointCs, pointD);
// 0..3
// | :
// 1--2
if (trBA < trCD) {
// solid sides: A-B-C
points[0] = pointA;
points[1] = pointB;
points[2] = pointC;
points[3] = pointD;
}
else {
// The matrix is square
const dimension = Math.min(dimensionRight, dimensionTop);
// correct top right point to match the white module
correctedTopRight = this.correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension);
if (correctedTopRight == null) {
correctedTopRight = topRight;
}
// Redetermine the dimension using the corrected top right point
let dimensionCorrected = Math.max(this.transitionsBetween(topLeft, correctedTopRight).getTransitions(), this.transitionsBetween(bottomRight, correctedTopRight).getTransitions());
dimensionCorrected++;
if ((dimensionCorrected & 0x01) === 1) {
dimensionCorrected++;
}
bits = Detector.sampleGrid(this.image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionCorrected, dimensionCorrected);
// solid sides: B-C-D
points[0] = pointB;
points[1] = pointC;
points[2] = pointD;
points[3] = pointA;
}
return new DetectorResult(bits, [topLeft, bottomLeft, bottomRight, correctedTopRight]);
return points;
}
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a rectangular matrix
* Calculates the corner position of the white top right module.
*/
correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight) {
let corr = Detector.distance(bottomLeft, bottomRight) / dimensionTop;
let norm = Detector.distance(topLeft, topRight);
let cos = (topRight.getX() - topLeft.getX()) / norm;
let sin = (topRight.getY() - topLeft.getY()) / norm;
const c1 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
corr = Detector.distance(bottomLeft, topLeft) / dimensionRight;
norm = Detector.distance(bottomRight, topRight);
cos = (topRight.getX() - bottomRight.getX()) / norm;
sin = (topRight.getY() - bottomRight.getY()) / norm;
const c2 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
if (!this.isValid(c1)) {
if (this.isValid(c2)) {
return c2;
correctTopRight(points) {
// A..D
// | :
// B--C
let pointA = points[0];
let pointB = points[1];
let pointC = points[2];
let pointD = points[3];
// shift points for safe transition detection.
let trTop = this.transitionsBetween(pointA, pointD);
let trRight = this.transitionsBetween(pointB, pointD);
let pointAs = Detector.shiftPoint(pointA, pointB, (trRight + 1) * 4);
let pointCs = Detector.shiftPoint(pointC, pointB, (trTop + 1) * 4);
trTop = this.transitionsBetween(pointAs, pointD);
trRight = this.transitionsBetween(pointCs, pointD);
let candidate1 = new ResultPoint(pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop + 1), pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop + 1));
let candidate2 = new ResultPoint(pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight + 1), pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight + 1));
if (!this.isValid(candidate1)) {
if (this.isValid(candidate2)) {
return candidate2;
}
return null;
}
if (!this.isValid(c2)) {
return c1;
if (!this.isValid(candidate2)) {
return candidate1;
}
const l1 = Math.abs(dimensionTop - this.transitionsBetween(topLeft, c1).getTransitions()) +
Math.abs(dimensionRight - this.transitionsBetween(bottomRight, c1).getTransitions());
const l2 = Math.abs(dimensionTop - this.transitionsBetween(topLeft, c2).getTransitions()) +
Math.abs(dimensionRight - this.transitionsBetween(bottomRight, c2).getTransitions());
if (l1 <= l2) {
return c1;
let sumc1 = this.transitionsBetween(pointAs, candidate1) + this.transitionsBetween(pointCs, candidate1);
let sumc2 = this.transitionsBetween(pointAs, candidate2) + this.transitionsBetween(pointCs, candidate2);
if (sumc1 > sumc2) {
return candidate1;
}
return c2;
else {
return candidate2;
}
}
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a square matrix
* Shift the edge points to the module center.
*/
correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension) {
let corr = Detector.distance(bottomLeft, bottomRight) / dimension;
let norm = Detector.distance(topLeft, topRight);
let cos = (topRight.getX() - topLeft.getX()) / norm;
let sin = (topRight.getY() - topLeft.getY()) / norm;
const c1 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
corr = Detector.distance(bottomLeft, topLeft) / dimension;
norm = Detector.distance(bottomRight, topRight);
cos = (topRight.getX() - bottomRight.getX()) / norm;
sin = (topRight.getY() - bottomRight.getY()) / norm;
const c2 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
if (!this.isValid(c1)) {
if (this.isValid(c2)) {
return c2;
}
return null;
shiftToModuleCenter(points) {
// A..D
// | :
// B--C
let pointA = points[0];
let pointB = points[1];
let pointC = points[2];
let pointD = points[3];
// calculate pseudo dimensions
let dimH = this.transitionsBetween(pointA, pointD) + 1;
let dimV = this.transitionsBetween(pointC, pointD) + 1;
// shift points for safe dimension detection
let pointAs = Detector.shiftPoint(pointA, pointB, dimV * 4);
let pointCs = Detector.shiftPoint(pointC, pointB, dimH * 4);
// calculate more precise dimensions
dimH = this.transitionsBetween(pointAs, pointD) + 1;
dimV = this.transitionsBetween(pointCs, pointD) + 1;
if ((dimH & 0x01) === 1) {
dimH += 1;
}
if (!this.isValid(c2)) {
return c1;
if ((dimV & 0x01) === 1) {
dimV += 1;
}
const l1 = Math.abs(this.transitionsBetween(topLeft, c1).getTransitions() -
this.transitionsBetween(bottomRight, c1).getTransitions());
const l2 = Math.abs(this.transitionsBetween(topLeft, c2).getTransitions() -
this.transitionsBetween(bottomRight, c2).getTransitions());
return l1 <= l2 ? c1 : c2;
// WhiteRectangleDetector returns points inside of the rectangle.
// I want points on the edges.
let centerX = (pointA.getX() + pointB.getX() + pointC.getX() + pointD.getX()) / 4;
let centerY = (pointA.getY() + pointB.getY() + pointC.getY() + pointD.getY()) / 4;
pointA = Detector.moveAway(pointA, centerX, centerY);
pointB = Detector.moveAway(pointB, centerX, centerY);
pointC = Detector.moveAway(pointC, centerX, centerY);
pointD = Detector.moveAway(pointD, centerX, centerY);
let pointBs;
let pointDs;
// shift points to the center of each modules
pointAs = Detector.shiftPoint(pointA, pointB, dimV * 4);
pointAs = Detector.shiftPoint(pointAs, pointD, dimH * 4);
pointBs = Detector.shiftPoint(pointB, pointA, dimV * 4);
pointBs = Detector.shiftPoint(pointBs, pointC, dimH * 4);
pointCs = Detector.shiftPoint(pointC, pointD, dimV * 4);
pointCs = Detector.shiftPoint(pointCs, pointB, dimH * 4);
pointDs = Detector.shiftPoint(pointD, pointC, dimV * 4);
pointDs = Detector.shiftPoint(pointDs, pointA, dimH * 4);
return [pointAs, pointBs, pointCs, pointDs];
}

@@ -236,12 +256,2 @@ isValid(p) {

}
static distance(a, b) {
return MathUtils.round(ResultPoint.distance(a, b));
}
/**
* Increments the Integer associated with a key by one.
*/
static increment(table, key) {
const value = table.get(key);
table.set(key, value == null ? 1 : value + 1);
}
static sampleGrid(image, topLeft, bottomLeft, bottomRight, topRight, dimensionX, dimensionY) {

@@ -256,7 +266,7 @@ const sampler = GridSamplerInstance.getInstance();

// See QR Code Detector, sizeOfBlackWhiteBlackRun()
let fromX = from.getX() | 0;
let fromY = from.getY() | 0;
let toX = to.getX() | 0;
let toY = to.getY() | 0;
const steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);
let fromX = Math.trunc(from.getX());
let fromY = Math.trunc(from.getY());
let toX = Math.trunc(to.getX());
let toY = Math.trunc(to.getY());
let steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);
if (steep) {

@@ -270,11 +280,11 @@ let temp = fromX;

}
const dx = Math.abs(toX - fromX);
const dy = Math.abs(toY - fromY);
let dx = Math.abs(toX - fromX);
let dy = Math.abs(toY - fromY);
let error = -dx / 2;
const ystep = fromY < toY ? 1 : -1;
const xstep = fromX < toX ? 1 : -1;
let ystep = fromY < toY ? 1 : -1;
let xstep = fromX < toX ? 1 : -1;
let transitions = 0;
let inBlack = this.image.get(steep ? fromY : fromX, steep ? fromX : fromY);
for (let x = fromX, y = fromY; x !== toX; x += xstep) {
const isBlack = this.image.get(steep ? y : x, steep ? x : y);
let isBlack = this.image.get(steep ? y : x, steep ? x : y);
if (isBlack !== inBlack) {

@@ -293,28 +303,5 @@ transitions++;

}
return new ResultPointsAndTransitions(from, to, transitions);
return transitions;
}
}
class ResultPointsAndTransitions {
constructor(from, to, transitions) {
this.from = from;
this.to = to;
this.transitions = transitions;
}
getFrom() {
return this.from;
}
getTo() {
return this.to;
}
getTransitions() {
return this.transitions;
}
// @Override
toString() {
return this.from + '/' + this.to + '/' + this.transitions;
}
static resultPointsAndTransitionsComparator(o1, o2) {
return o1.getTransitions() - o2.getTransitions();
}
}
//# sourceMappingURL=Detector.js.map

@@ -810,3 +810,3 @@ "use strict";

// trying again
return setTimeout(function () { return loop(resolve, reject); }, _this._timeBetweenDecodingAttempts);
return setTimeout(loop, _this._timeBetweenDecodingAttempts, resolve, reject);
}

@@ -832,3 +832,3 @@ reject(e);

callbackFn(result, null);
setTimeout(function () { return loop(); }, _this.timeBetweenScansMillis);
setTimeout(loop, _this.timeBetweenScansMillis);
}

@@ -841,3 +841,3 @@ catch (e) {

// trying again
setTimeout(function () { return loop(); }, _this._timeBetweenDecodingAttempts);
setTimeout(loop, _this._timeBetweenDecodingAttempts);
}

@@ -844,0 +844,0 @@ }

@@ -88,3 +88,3 @@ "use strict";

HTMLCanvasElementLuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
this.crop(left, top, width, height);
_super.prototype.crop.call(this, left, top, width, height);
return this;

@@ -91,0 +91,0 @@ };

@@ -20,18 +20,21 @@ import BitMatrix from '../../common/BitMatrix';

detect(): DetectorResult;
private static shiftPoint;
private static moveAway;
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a rectangular matrix
* Detect a solid side which has minimum transition.
*/
private correctTopRightRectangular;
private detectSolid1;
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a square matrix
* Detect a second solid side next to first solid side.
*/
private detectSolid2;
/**
* Calculates the corner position of the white top right module.
*/
private correctTopRight;
private isValid;
private static distance;
/**
* Increments the Integer associated with a key by one.
* Shift the edge points to the module center.
*/
private static increment;
private shiftToModuleCenter;
private isValid;
private static sampleGrid;

@@ -38,0 +41,0 @@ /**

"use strict";
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -32,3 +6,2 @@ var ResultPoint_1 = require("../../ResultPoint");

var GridSamplerInstance_1 = require("../../common/GridSamplerInstance");
var MathUtils_1 = require("../../common/detector/MathUtils");
var WhiteRectangleDetector_1 = require("../../common/detector/WhiteRectangleDetector");

@@ -60,3 +33,3 @@ var NotFoundException_1 = require("../../NotFoundException");

this.image = image;
this.rectangleDetector = new WhiteRectangleDetector_1.default(image);
this.rectangleDetector = new WhiteRectangleDetector_1.default(this.image);
}

@@ -70,203 +43,213 @@ /**

Detector.prototype.detect = function () {
var e_1, _a;
var cornerPoints = this.rectangleDetector.detect();
var pointA = cornerPoints[0];
var pointB = cornerPoints[1];
var pointC = cornerPoints[2];
var pointD = cornerPoints[3];
// Point A and D are across the diagonal from one another,
// as are B and C. Figure out which are the solid black lines
// by counting transitions
var transitions = [];
transitions.push(this.transitionsBetween(pointA, pointB));
transitions.push(this.transitionsBetween(pointA, pointC));
transitions.push(this.transitionsBetween(pointB, pointD));
transitions.push(this.transitionsBetween(pointC, pointD));
transitions.sort(ResultPointsAndTransitions.resultPointsAndTransitionsComparator);
// Sort by number of transitions. First two will be the two solid sides; last two
// will be the two alternating black/white sides
var lSideOne = transitions[0];
var lSideTwo = transitions[1];
// Figure out which point is their intersection by tallying up the number of times we see the
// endpoints in the four endpoints. One will show up twice.
var pointCount = new Map();
Detector.increment(pointCount, lSideOne.getFrom());
Detector.increment(pointCount, lSideOne.getTo());
Detector.increment(pointCount, lSideTwo.getFrom());
Detector.increment(pointCount, lSideTwo.getTo());
var maybeTopLeft = null;
var bottomLeft = null;
var maybeBottomRight = null;
try {
for (var _b = __values(Array.from(pointCount.entries())), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), point = _d[0], value = _d[1];
if (value === 2) {
bottomLeft = point; // this is definitely the bottom left, then -- end of two L sides
}
else {
// Otherwise it's either top left or bottom right -- just assign the two arbitrarily now
if (maybeTopLeft == null) {
maybeTopLeft = point;
}
else {
maybeBottomRight = point;
}
}
}
var points = this.detectSolid1(cornerPoints);
points = this.detectSolid2(points);
points[3] = this.correctTopRight(points);
if (!points[3]) {
throw new NotFoundException_1.default();
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
points = this.shiftToModuleCenter(points);
var topLeft = points[0];
var bottomLeft = points[1];
var bottomRight = points[2];
var topRight = points[3];
var dimensionTop = this.transitionsBetween(topLeft, topRight) + 1;
var dimensionRight = this.transitionsBetween(bottomRight, topRight) + 1;
if ((dimensionTop & 0x01) === 1) {
dimensionTop += 1;
}
if (maybeTopLeft == null || bottomLeft == null || maybeBottomRight == null) {
throw new NotFoundException_1.default();
if ((dimensionRight & 0x01) === 1) {
dimensionRight += 1;
}
// Bottom left is correct but top left and bottom right might be switched
var corners = [maybeTopLeft, bottomLeft, maybeBottomRight];
// Use the dot product trick to sort them out
ResultPoint_1.default.orderBestPatterns(corners);
// Now we know which is which:
var bottomRight = corners[0];
bottomLeft = corners[1];
var topLeft = corners[2];
// Which point didn't we find in relation to the "L" sides? that's the top right corner
var topRight;
if (!pointCount.has(pointA)) {
topRight = pointA;
if (4 * dimensionTop < 7 * dimensionRight && 4 * dimensionRight < 7 * dimensionTop) {
// The matrix is square
dimensionTop = dimensionRight = Math.max(dimensionTop, dimensionRight);
}
else if (!pointCount.has(pointB)) {
topRight = pointB;
var bits = Detector.sampleGrid(this.image, topLeft, bottomLeft, bottomRight, topRight, dimensionTop, dimensionRight);
return new DetectorResult_1.default(bits, [topLeft, bottomLeft, bottomRight, topRight]);
};
Detector.shiftPoint = function (point, to, div) {
var x = (to.getX() - point.getX()) / (div + 1);
var y = (to.getY() - point.getY()) / (div + 1);
return new ResultPoint_1.default(point.getX() + x, point.getY() + y);
};
Detector.moveAway = function (point, fromX, fromY) {
var x = point.getX();
var y = point.getY();
if (x < fromX) {
x -= 1;
}
else if (!pointCount.has(pointC)) {
topRight = pointC;
else {
x += 1;
}
if (y < fromY) {
y -= 1;
}
else {
topRight = pointD;
y += 1;
}
// Next determine the dimension by tracing along the top or right side and counting black/white
// transitions. Since we start inside a black module, we should see a number of transitions
// equal to 1 less than the code dimension. Well, actually 2 less, because we are going to
// end on a black module:
// The top right point is actually the corner of a module, which is one of the two black modules
// adjacent to the white module at the top right. Tracing to that corner from either the top left
// or bottom right should work here.
var dimensionTop = this.transitionsBetween(topLeft, topRight).getTransitions();
var dimensionRight = this.transitionsBetween(bottomRight, topRight).getTransitions();
if ((dimensionTop & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionTop++;
return new ResultPoint_1.default(x, y);
};
/**
* Detect a solid side which has minimum transition.
*/
Detector.prototype.detectSolid1 = function (cornerPoints) {
// 0 2
// 1 3
var pointA = cornerPoints[0];
var pointB = cornerPoints[1];
var pointC = cornerPoints[3];
var pointD = cornerPoints[2];
var trAB = this.transitionsBetween(pointA, pointB);
var trBC = this.transitionsBetween(pointB, pointC);
var trCD = this.transitionsBetween(pointC, pointD);
var trDA = this.transitionsBetween(pointD, pointA);
// 0..3
// : :
// 1--2
var min = trAB;
var points = [pointD, pointA, pointB, pointC];
if (min > trBC) {
min = trBC;
points[0] = pointA;
points[1] = pointB;
points[2] = pointC;
points[3] = pointD;
}
dimensionTop += 2;
if ((dimensionRight & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionRight++;
if (min > trCD) {
min = trCD;
points[0] = pointB;
points[1] = pointC;
points[2] = pointD;
points[3] = pointA;
}
dimensionRight += 2;
var bits;
var correctedTopRight;
// Rectangular symbols are 6x16, 6x28, 10x24, 10x32, 14x32, or 14x44. If one dimension is more
// than twice the other, it's certainly rectangular, but to cut a bit more slack we accept it as
// rectangular if the bigger side is at least 7/4 times the other:
if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) {
// The matrix is rectangular
correctedTopRight =
this.correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight);
if (correctedTopRight == null) {
correctedTopRight = topRight;
}
dimensionTop = this.transitionsBetween(topLeft, correctedTopRight).getTransitions();
dimensionRight = this.transitionsBetween(bottomRight, correctedTopRight).getTransitions();
if ((dimensionTop & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionTop++;
}
if ((dimensionRight & 0x01) === 1) {
// it can't be odd, so, round... up?
dimensionRight++;
}
bits = Detector.sampleGrid(this.image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionTop, dimensionRight);
if (min > trDA) {
points[0] = pointC;
points[1] = pointD;
points[2] = pointA;
points[3] = pointB;
}
return points;
};
/**
* Detect a second solid side next to first solid side.
*/
Detector.prototype.detectSolid2 = function (points) {
// A..D
// : :
// B--C
var pointA = points[0];
var pointB = points[1];
var pointC = points[2];
var pointD = points[3];
// Transition detection on the edge is not stable.
// To safely detect, shift the points to the module center.
var tr = this.transitionsBetween(pointA, pointD);
var pointBs = Detector.shiftPoint(pointB, pointC, (tr + 1) * 4);
var pointCs = Detector.shiftPoint(pointC, pointB, (tr + 1) * 4);
var trBA = this.transitionsBetween(pointBs, pointA);
var trCD = this.transitionsBetween(pointCs, pointD);
// 0..3
// | :
// 1--2
if (trBA < trCD) {
// solid sides: A-B-C
points[0] = pointA;
points[1] = pointB;
points[2] = pointC;
points[3] = pointD;
}
else {
// The matrix is square
var dimension = Math.min(dimensionRight, dimensionTop);
// correct top right point to match the white module
correctedTopRight = this.correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension);
if (correctedTopRight == null) {
correctedTopRight = topRight;
}
// Redetermine the dimension using the corrected top right point
var dimensionCorrected = Math.max(this.transitionsBetween(topLeft, correctedTopRight).getTransitions(), this.transitionsBetween(bottomRight, correctedTopRight).getTransitions());
dimensionCorrected++;
if ((dimensionCorrected & 0x01) === 1) {
dimensionCorrected++;
}
bits = Detector.sampleGrid(this.image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionCorrected, dimensionCorrected);
// solid sides: B-C-D
points[0] = pointB;
points[1] = pointC;
points[2] = pointD;
points[3] = pointA;
}
return new DetectorResult_1.default(bits, [topLeft, bottomLeft, bottomRight, correctedTopRight]);
return points;
};
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a rectangular matrix
* Calculates the corner position of the white top right module.
*/
Detector.prototype.correctTopRightRectangular = function (bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight) {
var corr = Detector.distance(bottomLeft, bottomRight) / dimensionTop;
var norm = Detector.distance(topLeft, topRight);
var cos = (topRight.getX() - topLeft.getX()) / norm;
var sin = (topRight.getY() - topLeft.getY()) / norm;
var c1 = new ResultPoint_1.default(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
corr = Detector.distance(bottomLeft, topLeft) / dimensionRight;
norm = Detector.distance(bottomRight, topRight);
cos = (topRight.getX() - bottomRight.getX()) / norm;
sin = (topRight.getY() - bottomRight.getY()) / norm;
var c2 = new ResultPoint_1.default(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
if (!this.isValid(c1)) {
if (this.isValid(c2)) {
return c2;
Detector.prototype.correctTopRight = function (points) {
// A..D
// | :
// B--C
var pointA = points[0];
var pointB = points[1];
var pointC = points[2];
var pointD = points[3];
// shift points for safe transition detection.
var trTop = this.transitionsBetween(pointA, pointD);
var trRight = this.transitionsBetween(pointB, pointD);
var pointAs = Detector.shiftPoint(pointA, pointB, (trRight + 1) * 4);
var pointCs = Detector.shiftPoint(pointC, pointB, (trTop + 1) * 4);
trTop = this.transitionsBetween(pointAs, pointD);
trRight = this.transitionsBetween(pointCs, pointD);
var candidate1 = new ResultPoint_1.default(pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop + 1), pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop + 1));
var candidate2 = new ResultPoint_1.default(pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight + 1), pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight + 1));
if (!this.isValid(candidate1)) {
if (this.isValid(candidate2)) {
return candidate2;
}
return null;
}
if (!this.isValid(c2)) {
return c1;
if (!this.isValid(candidate2)) {
return candidate1;
}
var l1 = Math.abs(dimensionTop - this.transitionsBetween(topLeft, c1).getTransitions()) +
Math.abs(dimensionRight - this.transitionsBetween(bottomRight, c1).getTransitions());
var l2 = Math.abs(dimensionTop - this.transitionsBetween(topLeft, c2).getTransitions()) +
Math.abs(dimensionRight - this.transitionsBetween(bottomRight, c2).getTransitions());
if (l1 <= l2) {
return c1;
var sumc1 = this.transitionsBetween(pointAs, candidate1) + this.transitionsBetween(pointCs, candidate1);
var sumc2 = this.transitionsBetween(pointAs, candidate2) + this.transitionsBetween(pointCs, candidate2);
if (sumc1 > sumc2) {
return candidate1;
}
return c2;
else {
return candidate2;
}
};
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a square matrix
* Shift the edge points to the module center.
*/
Detector.prototype.correctTopRight = function (bottomLeft, bottomRight, topLeft, topRight, dimension) {
var corr = Detector.distance(bottomLeft, bottomRight) / dimension;
var norm = Detector.distance(topLeft, topRight);
var cos = (topRight.getX() - topLeft.getX()) / norm;
var sin = (topRight.getY() - topLeft.getY()) / norm;
var c1 = new ResultPoint_1.default(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
corr = Detector.distance(bottomLeft, topLeft) / dimension;
norm = Detector.distance(bottomRight, topRight);
cos = (topRight.getX() - bottomRight.getX()) / norm;
sin = (topRight.getY() - bottomRight.getY()) / norm;
var c2 = new ResultPoint_1.default(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
if (!this.isValid(c1)) {
if (this.isValid(c2)) {
return c2;
}
return null;
Detector.prototype.shiftToModuleCenter = function (points) {
// A..D
// | :
// B--C
var pointA = points[0];
var pointB = points[1];
var pointC = points[2];
var pointD = points[3];
// calculate pseudo dimensions
var dimH = this.transitionsBetween(pointA, pointD) + 1;
var dimV = this.transitionsBetween(pointC, pointD) + 1;
// shift points for safe dimension detection
var pointAs = Detector.shiftPoint(pointA, pointB, dimV * 4);
var pointCs = Detector.shiftPoint(pointC, pointB, dimH * 4);
// calculate more precise dimensions
dimH = this.transitionsBetween(pointAs, pointD) + 1;
dimV = this.transitionsBetween(pointCs, pointD) + 1;
if ((dimH & 0x01) === 1) {
dimH += 1;
}
if (!this.isValid(c2)) {
return c1;
if ((dimV & 0x01) === 1) {
dimV += 1;
}
var l1 = Math.abs(this.transitionsBetween(topLeft, c1).getTransitions() -
this.transitionsBetween(bottomRight, c1).getTransitions());
var l2 = Math.abs(this.transitionsBetween(topLeft, c2).getTransitions() -
this.transitionsBetween(bottomRight, c2).getTransitions());
return l1 <= l2 ? c1 : c2;
// WhiteRectangleDetector returns points inside of the rectangle.
// I want points on the edges.
var centerX = (pointA.getX() + pointB.getX() + pointC.getX() + pointD.getX()) / 4;
var centerY = (pointA.getY() + pointB.getY() + pointC.getY() + pointD.getY()) / 4;
pointA = Detector.moveAway(pointA, centerX, centerY);
pointB = Detector.moveAway(pointB, centerX, centerY);
pointC = Detector.moveAway(pointC, centerX, centerY);
pointD = Detector.moveAway(pointD, centerX, centerY);
var pointBs;
var pointDs;
// shift points to the center of each modules
pointAs = Detector.shiftPoint(pointA, pointB, dimV * 4);
pointAs = Detector.shiftPoint(pointAs, pointD, dimH * 4);
pointBs = Detector.shiftPoint(pointB, pointA, dimV * 4);
pointBs = Detector.shiftPoint(pointBs, pointC, dimH * 4);
pointCs = Detector.shiftPoint(pointC, pointD, dimV * 4);
pointCs = Detector.shiftPoint(pointCs, pointB, dimH * 4);
pointDs = Detector.shiftPoint(pointD, pointC, dimV * 4);
pointDs = Detector.shiftPoint(pointDs, pointA, dimH * 4);
return [pointAs, pointBs, pointCs, pointDs];
};

@@ -276,12 +259,2 @@ Detector.prototype.isValid = function (p) {

};
Detector.distance = function (a, b) {
return MathUtils_1.default.round(ResultPoint_1.default.distance(a, b));
};
/**
* Increments the Integer associated with a key by one.
*/
Detector.increment = function (table, key) {
var value = table.get(key);
table.set(key, value == null ? 1 : value + 1);
};
Detector.sampleGrid = function (image, topLeft, bottomLeft, bottomRight, topRight, dimensionX, dimensionY) {

@@ -296,6 +269,6 @@ var sampler = GridSamplerInstance_1.default.getInstance();

// See QR Code Detector, sizeOfBlackWhiteBlackRun()
var fromX = from.getX() | 0;
var fromY = from.getY() | 0;
var toX = to.getX() | 0;
var toY = to.getY() | 0;
var fromX = Math.trunc(from.getX());
var fromY = Math.trunc(from.getY());
var toX = Math.trunc(to.getX());
var toY = Math.trunc(to.getY());
var steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);

@@ -332,3 +305,3 @@ if (steep) {

}
return new ResultPointsAndTransitions(from, to, transitions);
return transitions;
};

@@ -338,26 +311,2 @@ return Detector;

exports.default = Detector;
var ResultPointsAndTransitions = /** @class */ (function () {
function ResultPointsAndTransitions(from, to, transitions) {
this.from = from;
this.to = to;
this.transitions = transitions;
}
ResultPointsAndTransitions.prototype.getFrom = function () {
return this.from;
};
ResultPointsAndTransitions.prototype.getTo = function () {
return this.to;
};
ResultPointsAndTransitions.prototype.getTransitions = function () {
return this.transitions;
};
// @Override
ResultPointsAndTransitions.prototype.toString = function () {
return this.from + '/' + this.to + '/' + this.transitions;
};
ResultPointsAndTransitions.resultPointsAndTransitionsComparator = function (o1, o2) {
return o1.getTransitions() - o2.getTransitions();
};
return ResultPointsAndTransitions;
}());
//# sourceMappingURL=Detector.js.map
{
"name": "@zxing/library",
"version": "0.17.0",
"description": "TypeScript port of ZXing multi-format 1D/2D barcode image processing library.",
"keywords": [
"reader",
"writer",
"decode",
"encode",
"scanner",
"generator",
"barcode",
"qr-code",
"barcode 1d",
"barcode 2d",
"typescript",
"zxing"
],
"authors": [
{
"name": "Adrian Toșcă"
},
{
"name": "David Werth",
"email": "werth.david@gmail.com"
},
{
"name": "Luiz Barni",
"email": "machado@odahcam.com"
}
],
"engines": {
"node": ">= 10.4.0"
"name": "@zxing/library",
"version": "0.17.1",
"description": "TypeScript port of ZXing multi-format 1D/2D barcode image processing library.",
"keywords": [
"reader",
"writer",
"decode",
"encode",
"scanner",
"generator",
"barcode",
"qr-code",
"barcode 1d",
"barcode 2d",
"typescript",
"zxing"
],
"authors": [
{
"name": "Adrian Toșcă"
},
"license": "MIT",
"bugs": "https://github.com/zxing-js/library/issues/new",
"repository": {
"type": "git",
"url": "https://github.com/zxing-js/library"
{
"name": "David Werth",
"email": "werth.david@gmail.com"
},
"homepage": "https://zxing-js.github.io/library/",
"private": false,
"main": "./umd/index.min.js",
"module": "./esm5/index.js",
"typings": "./esm/index.d.ts",
"esnext": "./esm/index.js",
"nyc": {
"include": [
"src/**/*.ts"
],
"sourceMap": false,
"instrument": false
},
"scripts": {
"lint": "yarn tslint --project .",
"clean": "yarn shx rm -rf umd esm esm5",
"test": "yarn mocha-webpack \"./src/**/*.spec.ts\" --timeout 200000 --webpack-config webpack.config.test.js",
"cover": "yarn nyc --reporter=lcov --reporter=text yarn test",
"build": "yarn clean && yarn build:es5 && yarn build:es6 && yarn build:umd",
"build:es5": "yarn tsc",
"build:es6": "yarn tsc --target es6 --outdir esm --module es6",
"build:umd": "yarn webpack --mode production",
"shx": "./node_modules/.bin/shx",
"tsc": "./node_modules/.bin/tsc",
"tslint": "./node_modules/.bin/tslint \"./src/**/*.ts\"",
"mocha-webpack": "./node_modules/.bin/mocha-webpack",
"nyc": "./node_modules/.bin/nyc",
"webpack": "./node_modules/.bin/webpack-cli"
},
"dependencies": {
"ts-custom-error": "^3.0.0"
},
"devDependencies": {
"@sinonjs/text-encoding": "^0.7.1",
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/node": "^10.12.29",
"@types/seedrandom": "^2.4.27",
"@types/sharp": "^0.22.2",
"awesome-typescript-loader": "^5.2.1",
"chai": "^4.2.0",
"codacy-coverage": "^3.4.0",
"eslint": "^5.15.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^3.1.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-remap-coverage": "^0.1.5",
"karma-sinon": "^1.0.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-typescript": "^3.0.13",
"karma-typescript-preprocessor": "^0.4.0",
"karma-webpack": "^3.0.5",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"mocha-webpack": "^2.0.0-beta.0",
"nyc": "^13.3.0",
"seedrandom": "^2.4.4",
"sharp": "^0.22.1",
"shx": "0.3.2",
"sinon": "^7.2.7",
"ts-loader": "^5.3.3",
"ts-node": "^8.9.0",
"tslint": "^5.13.1",
"tslint-no-circular-imports": "^0.7.0",
"typescript": "~3.3.3333",
"uglify-js": "^3.4.9",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3",
"webpack-config-utils": "2.3.1",
"webpack-node-externals": "^1.6.0",
"yarn": "^1.17.3"
},
"optionalDependencies": {
"@sinonjs/text-encoding": "0.7.1"
{
"name": "Luiz Barni",
"email": "machado@odahcam.com"
}
],
"engines": {
"node": ">= 10.4.0"
},
"license": "MIT",
"bugs": "https://github.com/zxing-js/library/issues/new",
"repository": {
"type": "git",
"url": "https://github.com/zxing-js/library"
},
"homepage": "https://zxing-js.github.io/library/",
"private": false,
"main": "./umd/index.min.js",
"module": "./esm5/index.js",
"typings": "./esm/index.d.ts",
"esnext": "./esm/index.js",
"nyc": {
"include": [
"src/**/*.ts"
],
"sourceMap": false,
"instrument": false
},
"scripts": {
"lint": "yarn tslint --project .",
"clean": "yarn shx rm -rf umd esm esm5",
"test": "yarn mocha-webpack \"./src/**/*.spec.ts\" --timeout 200000 --webpack-config webpack.config.test.js",
"cover": "yarn nyc --reporter=lcov --reporter=text yarn test",
"build": "yarn clean && yarn build:es5 && yarn build:es6 && yarn build:umd",
"build:es5": "yarn tsc",
"build:es6": "yarn tsc --target es6 --outdir esm --module es6",
"build:umd": "yarn webpack --mode production",
"shx": "./node_modules/.bin/shx",
"tsc": "./node_modules/.bin/tsc",
"tslint": "./node_modules/.bin/tslint \"./src/**/*.ts\"",
"mocha-webpack": "./node_modules/.bin/mocha-webpack",
"nyc": "./node_modules/.bin/nyc",
"webpack": "./node_modules/.bin/webpack-cli"
},
"dependencies": {
"ts-custom-error": "^3.0.0"
},
"devDependencies": {
"@zxing/text-encoding": "~0.9.0",
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/node": "^10.12.29",
"@types/seedrandom": "^2.4.27",
"@types/sharp": "^0.22.2",
"awesome-typescript-loader": "^5.2.1",
"chai": "^4.2.0",
"codacy-coverage": "^3.4.0",
"eslint": "^5.15.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^3.1.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-remap-coverage": "^0.1.5",
"karma-sinon": "^1.0.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-typescript": "^3.0.13",
"karma-typescript-preprocessor": "^0.4.0",
"karma-webpack": "^3.0.5",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"mocha-webpack": "^2.0.0-beta.0",
"nyc": "^13.3.0",
"seedrandom": "^2.4.4",
"sharp": "^0.22.1",
"shx": "0.3.2",
"sinon": "^7.2.7",
"ts-loader": "^5.3.3",
"ts-node": "^8.9.0",
"tslint": "^5.13.1",
"tslint-no-circular-imports": "^0.7.0",
"typescript": "~3.3.3333",
"uglify-js": "^3.4.9",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3",
"webpack-config-utils": "2.3.1",
"webpack-node-externals": "^1.6.0",
"yarn": "^1.17.3"
},
"optionalDependencies": {
"@zxing/text-encoding": "~0.9.0"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/zxing-js",
"logo": "https://opencollective.com/zxing-js/logo.txt"
}
}

@@ -155,3 +155,3 @@ [<img align="right" src="https://raw.github.com/wiki/zxing/zxing/zxing-logo.png"/>][1]

const luminanceSource = new RGBLuminanceSource(imgWidth, imgHeight, imgByteArray);
const luminanceSource = new RGBLuminanceSource(imgByteArray, imgWidth, imgHeight);
const binaryBitmap = new BinaryBitmap(new HybridBinarizer(luminanceSource));

@@ -158,0 +158,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc