mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Fixed minified code
This commit is contained in:
Vendored
+73
-136
@@ -71,6 +71,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
|
|
||||||
var _typedefs2 = _interopRequireDefault(_typedefs);
|
var _typedefs2 = _interopRequireDefault(_typedefs);
|
||||||
|
|
||||||
|
// eslint-disable-line no-unused-vars
|
||||||
|
|
||||||
var _input_stream = __webpack_require__(3);
|
var _input_stream = __webpack_require__(3);
|
||||||
|
|
||||||
var _input_stream2 = _interopRequireDefault(_input_stream);
|
var _input_stream2 = _interopRequireDefault(_input_stream);
|
||||||
@@ -165,12 +167,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
|
|
||||||
function initInputStream(cb) {
|
function initInputStream(cb) {
|
||||||
var video;
|
var video;
|
||||||
if (_config.inputStream.type == "VideoStream") {
|
if (_config.inputStream.type === "VideoStream") {
|
||||||
video = document.createElement("video");
|
video = document.createElement("video");
|
||||||
_inputStream = _input_stream2['default'].createVideoStream(video);
|
_inputStream = _input_stream2['default'].createVideoStream(video);
|
||||||
} else if (_config.inputStream.type == "ImageStream") {
|
} else if (_config.inputStream.type === "ImageStream") {
|
||||||
_inputStream = _input_stream2['default'].createImageStream();
|
_inputStream = _input_stream2['default'].createImageStream();
|
||||||
} else if (_config.inputStream.type == "LiveStream") {
|
} else if (_config.inputStream.type === "LiveStream") {
|
||||||
var $viewport = document.querySelector("#interactive.viewport");
|
var $viewport = document.querySelector("#interactive.viewport");
|
||||||
if ($viewport) {
|
if ($viewport) {
|
||||||
video = $viewport.querySelector("video");
|
video = $viewport.querySelector("video");
|
||||||
@@ -224,7 +226,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
if (!_canvasContainer.dom.image) {
|
if (!_canvasContainer.dom.image) {
|
||||||
_canvasContainer.dom.image = document.createElement("canvas");
|
_canvasContainer.dom.image = document.createElement("canvas");
|
||||||
_canvasContainer.dom.image.className = "imgBuffer";
|
_canvasContainer.dom.image.className = "imgBuffer";
|
||||||
if ($viewport && _config.inputStream.type == "ImageStream") {
|
if ($viewport && _config.inputStream.type === "ImageStream") {
|
||||||
$viewport.appendChild(_canvasContainer.dom.image);
|
$viewport.appendChild(_canvasContainer.dom.image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,7 +379,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
(function frame() {
|
(function frame() {
|
||||||
if (!_stopped) {
|
if (!_stopped) {
|
||||||
update();
|
update();
|
||||||
if (_onUIThread && _config.inputStream.type == "LiveStream") {
|
if (_onUIThread && _config.inputStream.type === "LiveStream") {
|
||||||
window.requestAnimFrame(frame);
|
window.requestAnimFrame(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,17 +438,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
function workerInterface(factory) {
|
function workerInterface(factory) {
|
||||||
window = self;
|
/* eslint-disable no-undef*/
|
||||||
if (factory) {
|
if (factory) {
|
||||||
/* jshint ignore:start */
|
|
||||||
var Quagga = factory();
|
var Quagga = factory();
|
||||||
if (!Quagga) {
|
if (!Quagga) {
|
||||||
self.postMessage({ 'event': 'error', message: 'Quagga could not be created' });
|
self.postMessage({ 'event': 'error', message: 'Quagga could not be created' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* jshint ignore:end */
|
|
||||||
}
|
}
|
||||||
/* jshint ignore:start */
|
|
||||||
var imageWrapper;
|
var imageWrapper;
|
||||||
|
|
||||||
self.onmessage = function (e) {
|
self.onmessage = function (e) {
|
||||||
@@ -468,13 +467,19 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onProcessed(result) {
|
function onProcessed(result) {
|
||||||
self.postMessage({ 'event': 'processed', imageData: imageWrapper.data, result: result }, [imageWrapper.data.buffer]);
|
self.postMessage({
|
||||||
|
'event': 'processed',
|
||||||
|
imageData: imageWrapper.data,
|
||||||
|
result: result
|
||||||
|
}, [imageWrapper.data.buffer]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ready() {
|
function ready() {
|
||||||
|
// eslint-disable-line
|
||||||
self.postMessage({ 'event': 'initialized', imageData: imageWrapper.data }, [imageWrapper.data.buffer]);
|
self.postMessage({ 'event': 'initialized', imageData: imageWrapper.data }, [imageWrapper.data.buffer]);
|
||||||
}
|
}
|
||||||
/* jshint ignore:end */
|
|
||||||
|
/* eslint-enable */
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateWorkerBlob() {
|
function generateWorkerBlob() {
|
||||||
@@ -482,7 +487,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
|
|
||||||
/* jshint ignore:start */
|
/* jshint ignore:start */
|
||||||
if (typeof __factorySource__ !== 'undefined') {
|
if (typeof __factorySource__ !== 'undefined') {
|
||||||
factorySource = __factorySource__;
|
factorySource = __factorySource__; // eslint-disable-line no-undef
|
||||||
}
|
}
|
||||||
/* jshint ignore:end */
|
/* jshint ignore:end */
|
||||||
|
|
||||||
@@ -697,7 +702,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
that.setCurrentTime = function (time) {
|
that.setCurrentTime = function (time) {
|
||||||
if (_config.type !== "LiveStream") video.currentTime = time;
|
if (_config.type !== "LiveStream") {
|
||||||
|
video.currentTime = time;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
that.addEventListener = function (event, f, bool) {
|
that.addEventListener = function (event, f, bool) {
|
||||||
@@ -832,12 +839,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
return calculatedHeight;
|
return calculatedHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.setWidth = function (width) {
|
that.setWidth = function (newWidth) {
|
||||||
calculatedWidth = width;
|
calculatedWidth = newWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.setHeight = function (height) {
|
that.setHeight = function (newHeight) {
|
||||||
calculatedHeight = height;
|
calculatedHeight = newHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.getRealWidth = function () {
|
that.getRealWidth = function () {
|
||||||
@@ -900,9 +907,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
return _topRight;
|
return _topRight;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.setCanvasSize = function (size) {
|
that.setCanvasSize = function (canvasSize) {
|
||||||
_canvasSize.x = size.x;
|
_canvasSize.x = canvasSize.x;
|
||||||
_canvasSize.y = size.y;
|
_canvasSize.y = canvasSize.y;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.getCanvasSize = function () {
|
that.getCanvasSize = function () {
|
||||||
@@ -961,17 +968,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
htmlImagesArray.notLoaded = [];
|
htmlImagesArray.notLoaded = [];
|
||||||
htmlImagesArray.addImage = function (img) {
|
htmlImagesArray.addImage = function (image) {
|
||||||
htmlImagesArray.notLoaded.push(img);
|
htmlImagesArray.notLoaded.push(image);
|
||||||
};
|
};
|
||||||
htmlImagesArray.loaded = function (loadedImg) {
|
htmlImagesArray.loaded = function (loadedImg) {
|
||||||
var notloadedImgs = htmlImagesArray.notLoaded;
|
var notloadedImgs = htmlImagesArray.notLoaded;
|
||||||
for (var x = 0; x < notloadedImgs.length; x++) {
|
for (var x = 0; x < notloadedImgs.length; x++) {
|
||||||
if (notloadedImgs[x] == loadedImg) {
|
if (notloadedImgs[x] === loadedImg) {
|
||||||
notloadedImgs.splice(x, 1);
|
notloadedImgs.splice(x, 1);
|
||||||
for (var y = 0; y < htmlImagesSrcArray.length; y++) {
|
for (var y = 0; y < htmlImagesSrcArray.length; y++) {
|
||||||
var imgName = htmlImagesSrcArray[y].substr(htmlImagesSrcArray[y].lastIndexOf("/"));
|
var imgName = htmlImagesSrcArray[y].substr(htmlImagesSrcArray[y].lastIndexOf("/"));
|
||||||
if (loadedImg.src.lastIndexOf(imgName) != -1) {
|
if (loadedImg.src.lastIndexOf(imgName) !== -1) {
|
||||||
htmlImagesArray[y] = loadedImg;
|
htmlImagesArray[y] = loadedImg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1067,67 +1074,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
return imgRef.x >= border && imgRef.y >= border && imgRef.x < this.size.x - border && imgRef.y < this.size.y - border;
|
return imgRef.x >= border && imgRef.y >= border && imgRef.x < this.size.x - border && imgRef.y < this.size.y - border;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Transforms an image according to the given affine-transformation matrix.
|
|
||||||
* @param inImg ImageWrapper a image containing the information to be extracted.
|
|
||||||
* @param outImg ImageWrapper the image to be filled. The whole image out image is filled by the in image.
|
|
||||||
* @param M mat2 the matrix used to map point in the out matrix to those in the in matrix
|
|
||||||
* @param inOrig vec2 origin in the in image
|
|
||||||
* @param outOrig vec2 origin in the out image
|
|
||||||
* @returns Number the number of pixels not in the in image
|
|
||||||
* @see cvd/vision.h
|
|
||||||
*/
|
|
||||||
ImageWrapper.transform = function (inImg, outImg, M, inOrig, outOrig) {
|
|
||||||
var w = outImg.size.x,
|
|
||||||
h = outImg.size.y,
|
|
||||||
iw = inImg.size.x,
|
|
||||||
ih = inImg.size.y;
|
|
||||||
var across = _glMatrix.vec2.clone([M[0], M[2]]);
|
|
||||||
var down = _glMatrix.vec2.clone([M[1], M[3]]);
|
|
||||||
var defaultValue = 0;
|
|
||||||
|
|
||||||
var p0 = _glMatrix.vec2.subtract(inOrig, _glMatrix.mat2.xVec2(M, outOrig, _glMatrix.vec2.clone()), _glMatrix.vec2.clone());
|
|
||||||
|
|
||||||
var min_x = p0[0],
|
|
||||||
min_y = p0[1];
|
|
||||||
var max_x = min_x,
|
|
||||||
max_y = min_y;
|
|
||||||
var p, i, j;
|
|
||||||
|
|
||||||
var sampleFunc = ImageWrapper.sample;
|
|
||||||
|
|
||||||
if (across[0] < 0) min_x += w * across[0];else max_x += w * across[0];
|
|
||||||
|
|
||||||
if (down[0] < 0) min_x += h * down[0];else max_x += h * down[0];
|
|
||||||
|
|
||||||
if (across[1] < 0) min_y += w * across[1];else max_y += w * across[1];
|
|
||||||
|
|
||||||
if (down[1] < 0) min_y += h * down[1];else max_y += h * down[1];
|
|
||||||
|
|
||||||
var carrigeReturn = _glMatrix.vec2.subtract(down, _glMatrix.vec2.scale(across, w, _glMatrix.vec2.clone()), _glMatrix.vec2.clone());
|
|
||||||
|
|
||||||
if (min_x >= 0 && min_y >= 0 && max_x < iw - 1 && max_y < ih - 1) {
|
|
||||||
p = p0;
|
|
||||||
for (i = 0; i < h; ++i, _glMatrix.vec2.add(p, carrigeReturn)) for (j = 0; j < w; ++j, _glMatrix.vec2.add(p, across)) outImg.set(j, i, sampleFunc(inImg, p[0], p[1]));
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
var x_bound = iw - 1;
|
|
||||||
var y_bound = ih - 1;
|
|
||||||
var count = 0;
|
|
||||||
p = p0;
|
|
||||||
for (i = 0; i < h; ++i, _glMatrix.vec2.add(p, carrigeReturn)) {
|
|
||||||
for (j = 0; j < w; ++j, _glMatrix.vec2.add(p, across)) {
|
|
||||||
if (0 <= p[0] && 0 <= p[1] && p[0] < x_bound && p[1] < y_bound) {
|
|
||||||
outImg.set(j, i, sampleFunc(inImg, p[0], p[1]));
|
|
||||||
} else {
|
|
||||||
outImg.set(j, i, defaultValue);++count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs bilinear sampling
|
* Performs bilinear sampling
|
||||||
* @param inImg Image to extract sample from
|
* @param inImg Image to extract sample from
|
||||||
@@ -1828,12 +1774,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
property = "rad";
|
property = "rad";
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToCluster(point) {
|
function addToCluster(newPoint) {
|
||||||
var found = false;
|
var found = false;
|
||||||
for (k = 0; k < clusters.length; k++) {
|
for (k = 0; k < clusters.length; k++) {
|
||||||
cluster = clusters[k];
|
cluster = clusters[k];
|
||||||
if (cluster.fits(point)) {
|
if (cluster.fits(newPoint)) {
|
||||||
cluster.add(point);
|
cluster.add(newPoint);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1847,7 +1793,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
clusters.push(_cluster2['default'].create(point, threshold));
|
clusters.push(_cluster2['default'].create(point, threshold));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clusters;
|
return clusters;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1925,7 +1870,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
result = top;
|
result = top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1952,10 +1896,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
yStart2 = v + 1;
|
yStart2 = v + 1;
|
||||||
xStart1 = u - 1;
|
xStart1 = u - 1;
|
||||||
xStart2 = u + 1;
|
xStart2 = u + 1;
|
||||||
sum = inImageData[yStart1 * width + xStart1] /* + inImageData[yStart1*width+u] */ + inImageData[yStart1 * width + xStart2] +
|
sum = inImageData[yStart1 * width + xStart1] + inImageData[yStart1 * width + xStart2] + inImageData[v * width + u] + inImageData[yStart2 * width + xStart1] + inImageData[yStart2 * width + xStart2];
|
||||||
/* inImageData[v*width+xStart1] + */
|
|
||||||
inImageData[v * width + u] + /* inImageData[v*width+xStart2] +*/
|
|
||||||
inImageData[yStart2 * width + xStart1] /* + inImageData[yStart2*width+u]*/ + inImageData[yStart2 * width + xStart2];
|
|
||||||
outImageData[v * width + u] = sum > 0 ? 1 : 0;
|
outImageData[v * width + u] = sum > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1980,10 +1921,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
yStart2 = v + 1;
|
yStart2 = v + 1;
|
||||||
xStart1 = u - 1;
|
xStart1 = u - 1;
|
||||||
xStart2 = u + 1;
|
xStart2 = u + 1;
|
||||||
sum = inImageData[yStart1 * width + xStart1] /* + inImageData[yStart1*width+u] */ + inImageData[yStart1 * width + xStart2] +
|
sum = inImageData[yStart1 * width + xStart1] + inImageData[yStart1 * width + xStart2] + inImageData[v * width + u] + inImageData[yStart2 * width + xStart1] + inImageData[yStart2 * width + xStart2];
|
||||||
/* inImageData[v*width+xStart1] + */
|
|
||||||
inImageData[v * width + u] + /* inImageData[v*width+xStart2] +*/
|
|
||||||
inImageData[yStart2 * width + xStart1] /* + inImageData[yStart2*width+u]*/ + inImageData[yStart2 * width + xStart2];
|
|
||||||
outImageData[v * width + u] = sum === 5 ? 1 : 0;
|
outImageData[v * width + u] = sum === 5 ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2112,7 +2050,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.loadImageArray = function (src, callback, canvas) {
|
CVUtils.loadImageArray = function (src, callback, canvas) {
|
||||||
if (!canvas) canvas = document.createElement('canvas');
|
if (!canvas) {
|
||||||
|
canvas = document.createElement('canvas');
|
||||||
|
}
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.callback = callback;
|
img.callback = callback;
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
@@ -2167,6 +2107,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
r = 0,
|
r = 0,
|
||||||
g = 0,
|
g = 0,
|
||||||
b = 0;
|
b = 0;
|
||||||
|
|
||||||
rgb = rgb || [0, 0, 0];
|
rgb = rgb || [0, 0, 0];
|
||||||
|
|
||||||
if (h < 60) {
|
if (h < 60) {
|
||||||
@@ -2361,9 +2302,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
updateCenter();
|
updateCenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _add(point) {
|
function _add(pointToAdd) {
|
||||||
pointMap[point.id] = point;
|
pointMap[pointToAdd.id] = pointToAdd;
|
||||||
points.push(point);
|
points.push(pointToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCenter() {
|
function updateCenter() {
|
||||||
@@ -2379,15 +2320,15 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
add: function add(point) {
|
add: function add(pointToAdd) {
|
||||||
if (!pointMap[point.id]) {
|
if (!pointMap[pointToAdd.id]) {
|
||||||
_add(point);
|
_add(pointToAdd);
|
||||||
updateCenter();
|
updateCenter();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fits: function fits(point) {
|
fits: function fits(otherPoint) {
|
||||||
// check cosine similarity to center-angle
|
// check cosine similarity to center-angle
|
||||||
var similarity = Math.abs(_glMatrix.vec2.dot(point.point.vec, center.vec));
|
var similarity = Math.abs(_glMatrix.vec2.dot(otherPoint.point.vec, center.vec));
|
||||||
if (similarity > threshold) {
|
if (similarity > threshold) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2401,10 +2342,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
createPoint: function createPoint(point, id, property) {
|
createPoint: function createPoint(newPoint, id, property) {
|
||||||
return {
|
return {
|
||||||
rad: point[property],
|
rad: newPoint[property],
|
||||||
point: point,
|
point: newPoint,
|
||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -7512,8 +7453,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
_inputImageWrapper,
|
_inputImageWrapper,
|
||||||
_skeletonizer,
|
_skeletonizer,
|
||||||
vec2 = _glMatrix2['default'].vec2,
|
vec2 = _glMatrix2['default'].vec2,
|
||||||
mat2 = _glMatrix2['default'].mat2,
|
mat2 = _glMatrix2['default'].mat2;
|
||||||
self = typeof window !== 'undefined' ? window : self;
|
|
||||||
|
|
||||||
function initBuffers() {
|
function initBuffers() {
|
||||||
var skeletonImageData;
|
var skeletonImageData;
|
||||||
@@ -7539,7 +7479,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
skeletonImageData = new ArrayBuffer(64 * 1024);
|
skeletonImageData = new ArrayBuffer(64 * 1024);
|
||||||
_subImageWrapper = new _image_wrapper2['default'](_patchSize, new Uint8Array(skeletonImageData, 0, _patchSize.x * _patchSize.y));
|
_subImageWrapper = new _image_wrapper2['default'](_patchSize, new Uint8Array(skeletonImageData, 0, _patchSize.x * _patchSize.y));
|
||||||
_skelImageWrapper = new _image_wrapper2['default'](_patchSize, new Uint8Array(skeletonImageData, _patchSize.x * _patchSize.y * 3, _patchSize.x * _patchSize.y), undefined, true);
|
_skelImageWrapper = new _image_wrapper2['default'](_patchSize, new Uint8Array(skeletonImageData, _patchSize.x * _patchSize.y * 3, _patchSize.x * _patchSize.y), undefined, true);
|
||||||
_skeletonizer = (0, _skeletonizer3['default'])(self, {
|
_skeletonizer = (0, _skeletonizer3['default'])(typeof window !== 'undefined' ? window : self, {
|
||||||
size: _patchSize.x
|
size: _patchSize.x
|
||||||
}, skeletonImageData);
|
}, skeletonImageData);
|
||||||
|
|
||||||
@@ -7911,7 +7851,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
var x,
|
var x,
|
||||||
y,
|
y,
|
||||||
currentPatch,
|
currentPatch,
|
||||||
patch,
|
|
||||||
idx,
|
idx,
|
||||||
dir,
|
dir,
|
||||||
current = {
|
current = {
|
||||||
@@ -7935,9 +7874,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
patch = _imageToPatchGrid.data[idx];
|
|
||||||
if (_patchLabelGrid.data[idx] === 0) {
|
if (_patchLabelGrid.data[idx] === 0) {
|
||||||
similarity = Math.abs(vec2.dot(patch.vec, currentPatch.vec));
|
similarity = Math.abs(vec2.dot(_imageToPatchGrid.data[idx].vec, currentPatch.vec));
|
||||||
if (similarity > threshold) {
|
if (similarity > threshold) {
|
||||||
trace(idx);
|
trace(idx);
|
||||||
}
|
}
|
||||||
@@ -8341,7 +8279,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
do {
|
do {
|
||||||
current.dir = (current.dir + 6) % 8;
|
current.dir = (current.dir + 6) % 8;
|
||||||
_trace(current, color, label, edgelabel);
|
_trace(current, color, label, edgelabel);
|
||||||
if (ldir != current.dir) {
|
if (ldir !== current.dir) {
|
||||||
Cv.dir = current.dir;
|
Cv.dir = current.dir;
|
||||||
P = vertex2D(current.cx, current.cy, 0);
|
P = vertex2D(current.cx, current.cy, 0);
|
||||||
P.prev = Cv;
|
P.prev = Cv;
|
||||||
@@ -8354,7 +8292,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
Cv.y = current.cy;
|
Cv.y = current.cy;
|
||||||
}
|
}
|
||||||
ldir = current.dir;
|
ldir = current.dir;
|
||||||
} while (current.cx != sx || current.cy != sy);
|
} while (current.cx !== sx || current.cy !== sy);
|
||||||
Fv.prev = Cv.prev;
|
Fv.prev = Cv.prev;
|
||||||
Cv.prev.next = Fv;
|
Cv.prev.next = Fv;
|
||||||
}
|
}
|
||||||
@@ -8380,6 +8318,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
/***/ function(module, exports) {
|
/***/ function(module, exports) {
|
||||||
|
|
||||||
/* @preserve ASM BEGIN */
|
/* @preserve ASM BEGIN */
|
||||||
|
/* eslint-disable eqeqeq*/
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
@@ -8578,9 +8517,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
skeletonize: skeletonize
|
skeletonize: skeletonize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/* @preserve ASM END */
|
|
||||||
|
|
||||||
exports["default"] = Skeletonizer;
|
exports["default"] = Skeletonizer;
|
||||||
|
|
||||||
|
/* eslint-enable eqeqeq*/
|
||||||
|
/* @preserve ASM END */
|
||||||
module.exports = exports["default"];
|
module.exports = exports["default"];
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
@@ -8691,7 +8632,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
|
|
||||||
var _i2of5_reader2 = _interopRequireDefault(_i2of5_reader);
|
var _i2of5_reader2 = _interopRequireDefault(_i2of5_reader);
|
||||||
|
|
||||||
var readers = {
|
var READERS = {
|
||||||
code_128_reader: _code_128_reader2['default'],
|
code_128_reader: _code_128_reader2['default'],
|
||||||
ean_reader: _ean_reader2['default'],
|
ean_reader: _ean_reader2['default'],
|
||||||
ean_8_reader: _ean_8_reader2['default'],
|
ean_8_reader: _ean_8_reader2['default'],
|
||||||
@@ -8755,16 +8696,16 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
function initReaders() {
|
function initReaders() {
|
||||||
config.readers.forEach(function (readerConfig) {
|
config.readers.forEach(function (readerConfig) {
|
||||||
var reader,
|
var reader,
|
||||||
config = {};
|
configuration = {};
|
||||||
|
|
||||||
if (typeof readerConfig === 'object') {
|
if (typeof readerConfig === 'object') {
|
||||||
reader = readerConfig.format;
|
reader = readerConfig.format;
|
||||||
config = readerConfig.config;
|
configuration = readerConfig.config;
|
||||||
} else if (typeof readerConfig === 'string') {
|
} else if (typeof readerConfig === 'string') {
|
||||||
reader = readerConfig;
|
reader = readerConfig;
|
||||||
}
|
}
|
||||||
console.log("Before registering reader: ", reader);
|
console.log("Before registering reader: ", reader);
|
||||||
_barcodeReaders.push(new readers[reader](config));
|
_barcodeReaders.push(new READERS[reader](configuration));
|
||||||
});
|
});
|
||||||
console.log("Registered Readers: " + _barcodeReaders.map(function (reader) {
|
console.log("Registered Readers: " + _barcodeReaders.map(function (reader) {
|
||||||
return JSON.stringify({ format: reader.FORMAT, config: reader.config });
|
return JSON.stringify({ format: reader.FORMAT, config: reader.config });
|
||||||
@@ -10335,7 +10276,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
var code = result.code;
|
var code = result.code;
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = code.replace(patterns.IOQ, '');
|
code = code.replace(patterns.IOQ, '');
|
||||||
@@ -10506,10 +10447,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
["space", "bar"].forEach(function (key) {
|
["space", "bar"].forEach(function (key) {
|
||||||
var kind = categorization[key];
|
var newkind = categorization[key];
|
||||||
kind.wide.min = Math.floor((kind.narrow.size / kind.narrow.counts + kind.wide.size / kind.wide.counts) / 2);
|
newkind.wide.min = Math.floor((newkind.narrow.size / newkind.narrow.counts + newkind.wide.size / newkind.wide.counts) / 2);
|
||||||
kind.narrow.max = Math.ceil(kind.wide.min);
|
newkind.narrow.max = Math.ceil(newkind.wide.min);
|
||||||
kind.wide.max = Math.ceil((kind.wide.size * self.MAX_ACCEPTABLE + self.PADDING) / kind.wide.counts);
|
newkind.wide.max = Math.ceil((newkind.wide.size * self.MAX_ACCEPTABLE + self.PADDING) / newkind.wide.counts);
|
||||||
});
|
});
|
||||||
|
|
||||||
return categorization;
|
return categorization;
|
||||||
@@ -10691,7 +10632,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
UPCReader.prototype._decode = function () {
|
UPCReader.prototype._decode = function () {
|
||||||
var result = _ean_reader2["default"].prototype._decode.call(this);
|
var result = _ean_reader2["default"].prototype._decode.call(this);
|
||||||
|
|
||||||
console.log("result", result);
|
|
||||||
if (result && result.code && result.code.length === 13 && result.code.charAt(0) === "0") {
|
if (result && result.code && result.code.length === 13 && result.code.charAt(0) === "0") {
|
||||||
result.code = result.code.substring(1);
|
result.code = result.code.substring(1);
|
||||||
return result;
|
return result;
|
||||||
@@ -10817,13 +10757,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
UPCEReader.prototype._determineParity = function (codeFrequency, result) {
|
UPCEReader.prototype._determineParity = function (codeFrequency, result) {
|
||||||
var self = this,
|
var i, nrSystem;
|
||||||
i,
|
|
||||||
nrSystem;
|
|
||||||
|
|
||||||
for (nrSystem = 0; nrSystem < self.CODE_FREQUENCY.length; nrSystem++) {
|
for (nrSystem = 0; nrSystem < this.CODE_FREQUENCY.length; nrSystem++) {
|
||||||
for (i = 0; i < self.CODE_FREQUENCY[nrSystem].length; i++) {
|
for (i = 0; i < this.CODE_FREQUENCY[nrSystem].length; i++) {
|
||||||
if (codeFrequency === self.CODE_FREQUENCY[nrSystem][i]) {
|
if (codeFrequency === this.CODE_FREQUENCY[nrSystem][i]) {
|
||||||
result.unshift(nrSystem);
|
result.unshift(nrSystem);
|
||||||
result.push(i);
|
result.push(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -12788,7 +12726,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
;
|
|
||||||
module.exports = exports["default"];
|
module.exports = exports["default"];
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
|
|||||||
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
+4
-6
File diff suppressed because one or more lines are too long
+2
-1
@@ -38,7 +38,8 @@
|
|||||||
"doc": "doc"
|
"doc": "doc"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "karma start"
|
"test": "karma start",
|
||||||
|
"build": "webpack && webpack --config webpack.config.min.js && grunt uglyasm"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ var _config,
|
|||||||
_inputImageWrapper,
|
_inputImageWrapper,
|
||||||
_skeletonizer,
|
_skeletonizer,
|
||||||
vec2 = glMatrix.vec2,
|
vec2 = glMatrix.vec2,
|
||||||
mat2 = glMatrix.mat2,
|
mat2 = glMatrix.mat2;
|
||||||
self = (typeof window !== 'undefined') ? window : self; // eslint-disable-line consistent-this
|
|
||||||
|
|
||||||
function initBuffers() {
|
function initBuffers() {
|
||||||
var skeletonImageData;
|
var skeletonImageData;
|
||||||
@@ -59,7 +58,7 @@ function initBuffers() {
|
|||||||
_skelImageWrapper = new ImageWrapper(_patchSize,
|
_skelImageWrapper = new ImageWrapper(_patchSize,
|
||||||
new Uint8Array(skeletonImageData, _patchSize.x * _patchSize.y * 3, _patchSize.x * _patchSize.y),
|
new Uint8Array(skeletonImageData, _patchSize.x * _patchSize.y * 3, _patchSize.x * _patchSize.y),
|
||||||
undefined, true);
|
undefined, true);
|
||||||
_skeletonizer = skeletonizer(self, {
|
_skeletonizer = skeletonizer((typeof window !== 'undefined') ? window : self, {
|
||||||
size: _patchSize.x
|
size: _patchSize.x
|
||||||
}, skeletonImageData);
|
}, skeletonImageData);
|
||||||
|
|
||||||
|
|||||||
@@ -347,7 +347,6 @@ function initWorker(cb) {
|
|||||||
|
|
||||||
function workerInterface(factory) {
|
function workerInterface(factory) {
|
||||||
/* eslint-disable no-undef*/
|
/* eslint-disable no-undef*/
|
||||||
window = self;
|
|
||||||
if (factory) {
|
if (factory) {
|
||||||
var Quagga = factory();
|
var Quagga = factory();
|
||||||
if (!Quagga) {
|
if (!Quagga) {
|
||||||
|
|||||||
+5
-3
@@ -1,4 +1,5 @@
|
|||||||
/* @preserve ASM BEGIN */
|
/* @preserve ASM BEGIN */
|
||||||
|
/* eslint-disable eqeqeq*/
|
||||||
function Skeletonizer(stdlib, foreign, buffer) {
|
function Skeletonizer(stdlib, foreign, buffer) {
|
||||||
"use asm";
|
"use asm";
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ function Skeletonizer(stdlib, foreign, buffer) {
|
|||||||
+ (images[(inImagePtr + offset + u) | 0] | 0)
|
+ (images[(inImagePtr + offset + u) | 0] | 0)
|
||||||
+ (images[(inImagePtr + yStart2 + xStart1) | 0] | 0)
|
+ (images[(inImagePtr + yStart2 + xStart1) | 0] | 0)
|
||||||
+ (images[(inImagePtr + yStart2 + xStart2) | 0] | 0)) | 0;
|
+ (images[(inImagePtr + yStart2 + xStart2) | 0] | 0)) | 0;
|
||||||
if ((sum | 0) === (5 | 0)) {
|
if ((sum | 0) == (5 | 0)) {
|
||||||
images[(outImagePtr + offset + u) | 0] = 1;
|
images[(outImagePtr + offset + u) | 0] = 1;
|
||||||
} else {
|
} else {
|
||||||
images[(outImagePtr + offset + u) | 0] = 0;
|
images[(outImagePtr + offset + u) | 0] = 0;
|
||||||
@@ -194,7 +195,7 @@ function Skeletonizer(stdlib, foreign, buffer) {
|
|||||||
bitwiseOr(skelImagePtr, tempImagePtr, skelImagePtr);
|
bitwiseOr(skelImagePtr, tempImagePtr, skelImagePtr);
|
||||||
memcpy(erodedImagePtr, subImagePtr);
|
memcpy(erodedImagePtr, subImagePtr);
|
||||||
sum = countNonZero(subImagePtr) | 0;
|
sum = countNonZero(subImagePtr) | 0;
|
||||||
done = ((sum | 0) === 0 | 0);
|
done = ((sum | 0) == 0 | 0);
|
||||||
} while (!done);
|
} while (!done);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +203,7 @@ function Skeletonizer(stdlib, foreign, buffer) {
|
|||||||
skeletonize: skeletonize
|
skeletonize: skeletonize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/* @preserve ASM END */
|
|
||||||
|
|
||||||
export default Skeletonizer;
|
export default Skeletonizer;
|
||||||
|
/* eslint-enable eqeqeq*/
|
||||||
|
/* @preserve ASM END */
|
||||||
|
|||||||
+24
-17
@@ -11,14 +11,17 @@ module.exports = function(grunt) {
|
|||||||
var code = fs.readFileSync('dist/quagga.js', 'utf-8'),
|
var code = fs.readFileSync('dist/quagga.js', 'utf-8'),
|
||||||
minifiedCode = fs.readFileSync('dist/quagga.min.js', 'utf-8'),
|
minifiedCode = fs.readFileSync('dist/quagga.min.js', 'utf-8'),
|
||||||
commentEnd = '/* @preserve ASM END */',
|
commentEnd = '/* @preserve ASM END */',
|
||||||
asmStartIdx = code.indexOf('/* @preserve ASM BEGIN */'),
|
moduleFunctionRegex = /function\s*\((\w+,\s*\w+)\)\s*\{\s*\/\* \@preserve ASM BEGIN \*\//,
|
||||||
asmEndIdx = code.indexOf(commentEnd),
|
commentStartIdx = code.indexOf("/* @preserve ASM BEGIN */"),
|
||||||
asmCode = code.substring(asmStartIdx, asmEndIdx + commentEnd.length),
|
asmEndIdxTmp = code.indexOf(commentEnd),
|
||||||
asmFunctionRegex = /function (\w+)\(\w+,\s*\w+,\s*\w+\)\s*\{\s*"use asm";/,
|
asmEndIdx = code.indexOf("}", asmEndIdxTmp),
|
||||||
|
asmCodeTmp = code.substring(commentStartIdx - Math.min(500, commentStartIdx),
|
||||||
|
asmEndIdx + 1),
|
||||||
|
asmStartIdx = asmCodeTmp.search(moduleFunctionRegex),
|
||||||
|
asmCode = asmCodeTmp.substring(asmStartIdx),
|
||||||
asmModule,
|
asmModule,
|
||||||
asmModuleName,
|
moduleArg1,
|
||||||
asmCodeMinified,
|
asmCodeMinified;
|
||||||
asmMinifiedModuleName;
|
|
||||||
|
|
||||||
asmCodeMinified = asmCode
|
asmCodeMinified = asmCode
|
||||||
.replace(/\s*\/\/.*/g, '') // remove single-line comments
|
.replace(/\s*\/\/.*/g, '') // remove single-line comments
|
||||||
@@ -29,28 +32,32 @@ module.exports = function(grunt) {
|
|||||||
|
|
||||||
grunt.log.debug(asmCodeMinified);
|
grunt.log.debug(asmCodeMinified);
|
||||||
|
|
||||||
asmModule = asmCode.match(asmFunctionRegex);
|
asmModule = moduleFunctionRegex.exec(asmCode);
|
||||||
if (!asmModule) {
|
if (!asmModule) {
|
||||||
grunt.log.error("No ASM module found");
|
grunt.log.error("No ASM module found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
asmModuleName = asmModule[1];
|
moduleArg1 = asmModule[1];
|
||||||
grunt.log.debug(asmModuleName);
|
grunt.log.debug(moduleArg1);
|
||||||
|
|
||||||
asmModule = minifiedCode.match(asmFunctionRegex);
|
var insertionPoint = minifiedCode.search(moduleFunctionRegex);
|
||||||
if (!asmModule) {
|
if (insertionPoint === -1) {
|
||||||
grunt.log.error("No ASM module found in minified file");
|
grunt.log.error("No ASM module found in minified file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
grunt.log.debug(insertionPoint);
|
||||||
|
|
||||||
asmMinifiedModuleName = asmModule[1];
|
var insertionPointEnd = minifiedCode.indexOf(commentEnd, insertionPoint);
|
||||||
grunt.log.debug(asmMinifiedModuleName);
|
insertionPointEnd = minifiedCode.indexOf("}", insertionPointEnd) + 1;
|
||||||
|
|
||||||
asmCodeMinified = asmCodeMinified.replace(asmModuleName, asmMinifiedModuleName);
|
grunt.log.debug(insertionPointEnd);
|
||||||
|
|
||||||
|
minifiedCode = minifiedCode.substring(0, insertionPoint)
|
||||||
|
+ asmCodeMinified
|
||||||
|
+ minifiedCode.substring(insertionPointEnd);
|
||||||
|
|
||||||
minifiedCode = minifiedCode.replace(/\/\* @preserve ASM BEGIN \*\/[^]*?\/\* @preserve ASM END \*\//, asmCodeMinified);
|
|
||||||
fs.writeFileSync('dist/quagga.min.js', minifiedCode);
|
fs.writeFileSync('dist/quagga.min.js', minifiedCode);
|
||||||
grunt.log.ok('dist/quagga.min.js written');
|
grunt.log.ok('dist/quagga.min.js written');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user