mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-13 05:31:37 +08:00
Merge pull request #22 from serratus/issue-22
Removing dependency on script-name, Ready for npm packaging
This commit is contained in:
+10
-4
@@ -10,7 +10,8 @@ module.exports = function(grunt) {
|
||||
},
|
||||
uglify : {
|
||||
options : {
|
||||
banner : '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
|
||||
banner : '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
|
||||
preserveComments: 'some'
|
||||
},
|
||||
build : {
|
||||
src : 'dist/<%= pkg.name %>.js',
|
||||
@@ -62,13 +63,18 @@ module.exports = function(grunt) {
|
||||
});
|
||||
|
||||
// Load the plugin that provides the "uglify" task.
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
|
||||
grunt.loadNpmTasks('grunt-requirejs');
|
||||
grunt.loadNpmTasks('grunt-karma');
|
||||
// Default task(s).
|
||||
grunt.registerTask('default', ['jshint', 'requirejs']);
|
||||
|
||||
grunt.loadTasks('tasks');
|
||||
|
||||
grunt.registerTask('build', ['check', 'requirejs']);
|
||||
grunt.registerTask('check', ['jshint']);
|
||||
grunt.registerTask('dist', ['build', 'uglify', 'uglyasm']);
|
||||
grunt.registerTask('test', ['karma']);
|
||||
|
||||
grunt.registerTask('default', ['build']);
|
||||
};
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
quaggaJS
|
||||
========
|
||||
|
||||
- [Changelog](#changelog) (2015-03-12)
|
||||
- [Changelog](#changelog) (2015-03-16)
|
||||
|
||||
QuaggaJS is a barcode-scanner entirely written in JavaScript supporting real-time localization and decoding of
|
||||
various types of barcodes such as __EAN__ and __CODE128__. The library is also capable of using `getUserMedia` to get direct
|
||||
access to the user's camera stream. Although the code relies on heavy image-processing even recent smartphones are
|
||||
capable of locating and decoding barcodes in real-time.
|
||||
## What is QuaggaJS?
|
||||
|
||||
Try some [examples](http://serratus.github.io/quaggaJS/examples) and check out the blog post
|
||||
([How barcode-localization works in QuaggaJS](http://www.oberhofer.co/how-barcode-localization-works-in-quaggajs/))
|
||||
QuaggaJS is a barcode-scanner entirely written in JavaScript supporting real-
|
||||
time localization and decoding of various types of barcodes such as __EAN__,
|
||||
__CODE128__ and __CODE39__. The library is also capable of using `getUserMedia`
|
||||
to get direct access to the user's camera stream. Although the code relies on
|
||||
heavy image-processing even recent smartphones are capable of locating and
|
||||
decoding barcodes in real-time.
|
||||
|
||||
Try some [examples](http://serratus.github.io/quaggaJS/examples) and check out
|
||||
the blog post ([How barcode-localization works in QuaggaJS][oberhofer_co_how])
|
||||
if you want to dive deeper into this topic.
|
||||
|
||||
![teaser][teaser_left]![teaser][teaser_right]
|
||||
@@ -17,63 +21,70 @@ if you want to dive deeper into this topic.
|
||||
|
||||
## Yet another barcode library?
|
||||
|
||||
This is not yet another port of the great [zxing][zxing_github] library, but more of an extension to it.
|
||||
This implementation features a barcode locator which is capable of finding a barcode-like pattern in an
|
||||
image resulting in an estimated bounding box including the rotation. Simply speaking, this reader is invariant
|
||||
to scale and rotation, whereas other libraries require the barcode to be aligned with the viewport.
|
||||
This is not yet another port of the great [zxing][zxing_github] library, but
|
||||
more of an extension to it. This implementation features a barcode locator which
|
||||
is capable of finding a barcode-like pattern in an image resulting in an
|
||||
estimated bounding box including the rotation. Simply speaking, this reader is
|
||||
invariant to scale and rotation, whereas other libraries require the barcode to
|
||||
be aligned with the viewport.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
In order to take full advantage of quaggaJS, the browser needs to support the `getUserMedia` API which is
|
||||
already implemented in recent versions of Firefox, Chrome and Opera. The API is also available on their
|
||||
mobile counterparts installed on Android. Safari and IE do not allow the access to the camera yet, neither
|
||||
on desktop, nor on mobile. You can check [caniuse][caniuse_getusermedia] for updates.
|
||||
In order to take full advantage of quaggaJS, the browser needs to support the
|
||||
`getUserMedia` API which is already implemented in recent versions of Firefox,
|
||||
Chrome and Opera. The API is also available on their mobile counterparts
|
||||
installed on Android. Safari and IE do not allow the access to the camera yet,
|
||||
neither on desktop, nor on mobile. You can check [caniuse][caniuse_getusermedia]
|
||||
for updates.
|
||||
|
||||
In cases where real-time decoding is not needed, or the platform does not support `getUserMedia` QuaggaJS is
|
||||
also capable of decoding image-files using the File API or other URL sources.
|
||||
In cases where real-time decoding is not needed, or the platform does not
|
||||
support `getUserMedia` QuaggaJS is also capable of decoding image-files using
|
||||
the File API or other URL sources.
|
||||
|
||||
## <a name="installation">Installation</a>
|
||||
## Getting Started
|
||||
|
||||
Just clone the repository and include `dist/quagga.js` in your project. You can also build the library yourself
|
||||
by simply typing:
|
||||
You can simply include `dist/quagga.min.js` in your project and you are ready
|
||||
to go.
|
||||
|
||||
If you want to keep your project modular, you can also install QuaggaJS via npm:
|
||||
|
||||
```console
|
||||
> npm install quagga
|
||||
```
|
||||
|
||||
And then import it as dependency in your project:
|
||||
|
||||
```javascript
|
||||
var quagga = require('quagga');
|
||||
```
|
||||
|
||||
For starters, have a look at the [examples][github_examples] to get an idea
|
||||
where to go from here.
|
||||
|
||||
## <a name="Building">Building</a>
|
||||
|
||||
You can build the library yourself by simply cloning the repo and typing:
|
||||
|
||||
```console
|
||||
> npm install
|
||||
> grunt
|
||||
> grunt dist
|
||||
```
|
||||
|
||||
### Minification
|
||||
This grunt task builds a non optimized version `quagga.js` and a minified
|
||||
version `quagga.min.js` and places both files in the `dist` folder.
|
||||
|
||||
Currently, I strongly disapprove using `grunt uglify` since it does not handle asm.js code correctly
|
||||
(see [issue](https://github.com/mishoo/UglifyJS2/issues/167)). The resulting code still works, but
|
||||
the performance might suffer, especially in Firefox. Additionally it triggers some ugly log-warnings
|
||||
in the console.
|
||||
## API
|
||||
|
||||
This is how you create a minified version of quaggaJS (saved in `dist/quagga.min.js`):
|
||||
|
||||
```console
|
||||
> grunt uglify
|
||||
```
|
||||
|
||||
Special care has to be taken if a minimized/uglified version of the code is needed. Basically the grunt task
|
||||
`grunt uglify` takes the `dist/quagga.js` as input and saves the minified code in `dist/quagga.min.js`.
|
||||
Since the introduction of web-workers in quaggaJS, the filename of the script is important, because
|
||||
the instantiation of the workers rely on it. This script-name defaults to `quagga.js` and can be changed
|
||||
in the config with the key `config.scriptName`. The supplied string must match the filename of the
|
||||
file being served by the webserver. Now, in the case of a minified version, the config must be adapted
|
||||
so that `config.scriptName` points to `quagga.min.js`.
|
||||
|
||||
See the [config](#configobject) for all supported options.
|
||||
|
||||
## Usage
|
||||
|
||||
You can check out the [examples](http://serratus.github.io/quaggaJS/examples) to get an idea of how to use QuaggaJS.
|
||||
Basically the library exposes the following API:
|
||||
You can check out the [examples][github_examples] to get an idea of how to
|
||||
use QuaggaJS. Basically the library exposes the following API:
|
||||
|
||||
### Quagga.init(config, callback)
|
||||
|
||||
This method initializes the library for a given configuration `config` (see below) and invokes the `callback` when Quagga is ready to start. The initialization process also requests for camera access if real-time detection is configured.
|
||||
This method initializes the library for a given configuration `config` (see
|
||||
below) and invokes the `callback` when Quagga is ready to start. The
|
||||
initialization process also requests for camera access if real-time detection is
|
||||
configured.
|
||||
|
||||
```javascript
|
||||
Quagga.init({
|
||||
@@ -92,31 +103,41 @@ Quagga.init({
|
||||
|
||||
### Quagga.start()
|
||||
|
||||
When the library is initialized, the `start()` method starts the video-stream and begins locating and decoding
|
||||
the images.
|
||||
When the library is initialized, the `start()` method starts the video-stream
|
||||
and begins locating and decoding the images.
|
||||
|
||||
### Quagga.stop()
|
||||
|
||||
If the decoder is currently running, after calling `stop()` the decoder does not process any more images. Additionally, if a camera-stream was requested upon initialization, this operation also disconnects the camera.
|
||||
If the decoder is currently running, after calling `stop()` the decoder does not
|
||||
process any more images. Additionally, if a camera-stream was requested upon
|
||||
initialization, this operation also disconnects the camera.
|
||||
|
||||
### Quagga.onProcessed(callback)
|
||||
|
||||
This method registers a `callback(data)` function that is called for each frame after the processing is done. The `data` object contains detailed information about the success/failure of the operation. The output varies, depending whether the detection and/or decoding were successful or not.
|
||||
This method registers a `callback(data)` function that is called for each frame
|
||||
after the processing is done. The `data` object contains detailed information
|
||||
about the success/failure of the operation. The output varies, depending whether
|
||||
the detection and/or decoding were successful or not.
|
||||
|
||||
### Quagga.onDetected(callback)
|
||||
|
||||
Registers a `callback(data)` function which is triggered whenever a barcode-pattern has been located and decoded
|
||||
successfully. The passed `data` object contains information about the decoding process including the detected code which can be obtained by calling `data.codeResult.code`.
|
||||
Registers a `callback(data)` function which is triggered whenever a barcode-
|
||||
pattern has been located and decoded successfully. The passed `data` object
|
||||
contains information about the decoding process including the detected code
|
||||
which can be obtained by calling `data.codeResult.code`.
|
||||
|
||||
### Quagga.decodeSingle(config, callback)
|
||||
|
||||
In contrast to the calls described above, this method does not rely on `getUserMedia` and operates on a
|
||||
single image instead. The provided callback is the same as in `onDetected` and contains the result `data`
|
||||
object.
|
||||
In contrast to the calls described above, this method does not rely on
|
||||
`getUserMedia` and operates on a single image instead. The provided callback
|
||||
is the same as in `onDetected` and contains the result `data` object.
|
||||
|
||||
## <a name="resultobject">The result object</a>
|
||||
|
||||
The callbacks passed into `onProcessed`, `onDetected` and `decodeSingle` receive a `data` object upon execution. The `data` object contains the following information. Depending on the success, some fields may be `undefined` or just empty.
|
||||
The callbacks passed into `onProcessed`, `onDetected` and `decodeSingle`
|
||||
receive a `data` object upon execution. The `data` object contains the following
|
||||
information. Depending on the success, some fields may be `undefined` or just
|
||||
empty.
|
||||
|
||||
```javascript
|
||||
{
|
||||
@@ -202,7 +223,6 @@ The default `config` object is set as followed:
|
||||
controls: false,
|
||||
locate: true,
|
||||
numOfWorkers: 4,
|
||||
scriptName: 'quagga.js',
|
||||
visual: {
|
||||
show: true
|
||||
},
|
||||
@@ -235,8 +255,9 @@ The default `config` object is set as followed:
|
||||
|
||||
## Examples
|
||||
|
||||
The following example takes an image `src` as input and prints the result on the console.
|
||||
The decoder is configured to detect _Code128_ barcodes and enables the locating-mechanism for more robust results.
|
||||
The following example takes an image `src` as input and prints the result on the
|
||||
console. The decoder is configured to detect _Code128_ barcodes and enables the
|
||||
locating-mechanism for more robust results.
|
||||
|
||||
```javascript
|
||||
Quagga.decodeSingle({
|
||||
@@ -250,7 +271,9 @@ Quagga.decodeSingle({
|
||||
|
||||
## Tests
|
||||
|
||||
Unit Tests can be run with [Karma][karmaUrl] and written using [Mocha][mochaUrl], [Chai][chaiUrl] and [SinonJS][sinonUrl]. Coverage reports are automatically generated in the coverage/ folder.
|
||||
Unit Tests can be run with [Karma][karmaUrl] and written using
|
||||
[Mocha][mochaUrl], [Chai][chaiUrl] and [SinonJS][sinonUrl]. Coverage reports are
|
||||
automatically generated in the coverage/ folder.
|
||||
|
||||
```console
|
||||
> npm install
|
||||
@@ -258,10 +281,21 @@ Unit Tests can be run with [Karma][karmaUrl] and written using [Mocha][mochaUrl]
|
||||
```
|
||||
## Image Debugging
|
||||
|
||||
In case you want to take a deeper dive into the inner workings of Quagga, get to know the _debugging_ capabilities of the current implementation. The various flags exposed through the `config` object give you the abilily to visualize almost every step in the processing. Because of the introduction of the web-workers, and their restriction not to have access to the DOM, the configuration must be explicitly set to `config.numOfWorkers = 0` in order to work.
|
||||
In case you want to take a deeper dive into the inner workings of Quagga, get to
|
||||
know the _debugging_ capabilities of the current implementation. The various
|
||||
flags exposed through the `config` object give you the abilily to visualize
|
||||
almost every step in the processing. Because of the introduction of the
|
||||
web-workers, and their restriction not to have access to the DOM, the
|
||||
configuration must be explicitly set to `config.numOfWorkers = 0` in order to
|
||||
work.
|
||||
|
||||
## <a name="changelog">Changelog</a>
|
||||
|
||||
### 2015-03-16
|
||||
- Improvements
|
||||
- now includes minified version (23.3KB gzipped)
|
||||
- No need for configuration of script-name any more
|
||||
|
||||
### 2015-03-12
|
||||
- Improvements
|
||||
- removed dependency on async.js
|
||||
@@ -272,16 +306,24 @@ In case you want to take a deeper dive into the inner workings of Quagga, get to
|
||||
|
||||
### 2015-01-21
|
||||
- Features
|
||||
- Added support for web-worker (using 4 workers as default, can be changed through `config.numOfWorkers`)
|
||||
- Due to the way how web-workers are created, the name of the script file (`config.scriptName`) should be kept in sync with your actual filename
|
||||
- Removed canvas-overlay for decoding (boxes & scanline) which can now be easily implemented using the existing API (see example)
|
||||
- Added support for web-worker (using 4 workers as default, can be changed
|
||||
through `config.numOfWorkers`)
|
||||
- Due to the way how web-workers are created, the name of the script file
|
||||
(`config.scriptName`) should be kept in sync with your actual filename
|
||||
- Removed canvas-overlay for decoding (boxes & scanline) which can now be
|
||||
easily implemented using the existing API (see example)
|
||||
- API Changes
|
||||
In the course of implementing web-workers some breaking changes were introduced to the API.
|
||||
- The `Quagga.init` function no longer receives the callback as part of the config but rather as a second argument: `Quagga.init(config, cb)`
|
||||
- The callback to `Quagga.onDetected` now receives an object containing much more information in addition to the decoded code. (see [data](#resultobject))
|
||||
- Added `Quagga.onProcessed(callback)` which provides a way to get information for each image processed.
|
||||
The callback receives the same `data` object as `Quagga.onDetected` does. Depending on the success of the process the `data` object
|
||||
might not contain any `resultCode` and/or `box` properties.
|
||||
In the course of implementing web-workers some breaking changes were
|
||||
introduced to the API.
|
||||
- The `Quagga.init` function no longer receives the callback as part of the
|
||||
config but rather as a second argument: `Quagga.init(config, cb)`
|
||||
- The callback to `Quagga.onDetected` now receives an object containing
|
||||
much more information in addition to the decoded code.(see
|
||||
[data](#resultobject))
|
||||
- Added `Quagga.onProcessed(callback)` which provides a way to get information
|
||||
for each image processed. The callback receives the same `data` object as
|
||||
`Quagga.onDetected` does. Depending on the success of the process the `data`
|
||||
object might not contain any `resultCode` and/or `box` properties.
|
||||
|
||||
[zxing_github]: https://github.com/zxing/zxing
|
||||
[teaser_left]: https://github.com/serratus/quaggaJS/blob/master/doc/img/mobile-located.png
|
||||
@@ -292,3 +334,5 @@ In the course of implementing web-workers some breaking changes were introduced
|
||||
[mochaUrl]: https://github.com/mochajs/mocha
|
||||
[karmaUrl]: http://karma-runner.github.io/
|
||||
[code39_wiki]: http://en.wikipedia.org/wiki/Code_39
|
||||
[oberhofer_co_how]: http://www.oberhofer.co/how-barcode-localization-works-in-quaggajs/
|
||||
[github_examples]: http://serratus.github.io/quaggaJS/examples
|
||||
|
||||
+6
-10
@@ -1,15 +1,11 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
//Allow using this built library as an AMD module
|
||||
//in another project. That other project will only
|
||||
//see this AMD call, not the internal modules in
|
||||
//the closure below.
|
||||
define([], factory);
|
||||
} else if (typeof module !== 'undefined') {
|
||||
module.exports = factory();
|
||||
var factorySource = factory.toString();
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = factory(factorySource);
|
||||
} else {
|
||||
//Browser globals case. Just assign the
|
||||
//result to a property on the global.
|
||||
root.Quagga = factory();
|
||||
root.Quagga = factory(factorySource);
|
||||
}
|
||||
}(this, function () {
|
||||
}(this, function (__factorySource__) {
|
||||
Vendored
+25
-46
@@ -1,18 +1,14 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
//Allow using this built library as an AMD module
|
||||
//in another project. That other project will only
|
||||
//see this AMD call, not the internal modules in
|
||||
//the closure below.
|
||||
define([], factory);
|
||||
} else if (typeof module !== 'undefined') {
|
||||
module.exports = factory();
|
||||
var factorySource = factory.toString();
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = factory(factorySource);
|
||||
} else {
|
||||
//Browser globals case. Just assign the
|
||||
//result to a property on the global.
|
||||
root.Quagga = factory();
|
||||
root.Quagga = factory(factorySource);
|
||||
}
|
||||
}(this, function () {/**
|
||||
}(this, function (__factorySource__) {/**
|
||||
* @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
|
||||
* Available via the MIT or new BSD license.
|
||||
* see: http://github.com/jrburke/almond for details
|
||||
@@ -3686,27 +3682,6 @@ define("glMatrix", ["typedefs"], (function (global) {
|
||||
};
|
||||
}(this)));
|
||||
|
||||
/*
|
||||
<augmentedJS: A javascript library for natural feature tracking>
|
||||
Copyright (C) 2011
|
||||
- Christoph Oberhofer (ar.oberhofer@gmail.com)
|
||||
- Jens Grubert (jg@jensgrubert.de)
|
||||
- Gerhard Reitmayr (reitmayr@icg.tugraz.at)
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* glMatrixAddon.js
|
||||
* Extension to the glMatrix library. The original glMatrix library
|
||||
@@ -5491,6 +5466,7 @@ define('rasterizer',["tracer"], function(Tracer) {
|
||||
define('skeletonizer',[],function() {
|
||||
|
||||
|
||||
/* @preserve ASM BEGIN */
|
||||
function Skeletonizer(stdlib, foreign, buffer) {
|
||||
"use asm";
|
||||
|
||||
@@ -5684,6 +5660,7 @@ define('skeletonizer',[],function() {
|
||||
skeletonize : skeletonize
|
||||
};
|
||||
}
|
||||
/* @preserve ASM END */
|
||||
|
||||
return Skeletonizer;
|
||||
});
|
||||
@@ -7048,7 +7025,6 @@ define('config',[],function(){
|
||||
controls: false,
|
||||
locate: true,
|
||||
numOfWorkers: 4,
|
||||
scriptName: 'quagga.js',
|
||||
visual: {
|
||||
show: true
|
||||
},
|
||||
@@ -7300,8 +7276,9 @@ define('camera_access',["html_utils"], function(HtmlUtils) {
|
||||
}
|
||||
};
|
||||
});
|
||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
||||
/* global define, vec2, importScripts */
|
||||
/* jshint undef: true, unused: true, browser:true, devel: true, evil: true */
|
||||
/* global define, vec2 */
|
||||
|
||||
|
||||
define('quagga',["code_128_reader", "ean_reader", "input_stream", "image_wrapper", "barcode_locator", "barcode_decoder", "frame_grabber", "html_utils", "config", "events", "camera_access", "image_debug"],
|
||||
function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, BarcodeDecoder, FrameGrabber, HtmlUtils, _config, Events, CameraAccess, ImageDebug) {
|
||||
@@ -7580,8 +7557,13 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
||||
}
|
||||
|
||||
|
||||
function workerInterface(scriptUrl) {
|
||||
importScripts(scriptUrl);
|
||||
function workerInterface(factory) {
|
||||
if (factory) {
|
||||
var Quagga = factory();
|
||||
if (!Quagga) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* jshint ignore:start */
|
||||
var imageWrapper;
|
||||
|
||||
@@ -7615,18 +7597,15 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
||||
|
||||
function generateWorkerBlob() {
|
||||
var blob,
|
||||
quaggaAbsoluteUrl,
|
||||
scripts = document.getElementsByTagName('script'),
|
||||
regex = new RegExp('\/' + _config.scriptName + '$');
|
||||
factorySource;
|
||||
|
||||
quaggaAbsoluteUrl = Array.prototype.slice.apply(scripts).filter(function(script) {
|
||||
return script.src && script.src.match(regex);
|
||||
}).map(function(script) {
|
||||
return script.src;
|
||||
})[0];
|
||||
/* jshint ignore:start */
|
||||
if (typeof __factorySource__ !== 'undefined') {
|
||||
factorySource = __factorySource__;
|
||||
}
|
||||
/* jshint ignore:end */
|
||||
|
||||
|
||||
blob = new Blob(['(' + workerInterface.toString() + ')("' + quaggaAbsoluteUrl + '");'],
|
||||
blob = new Blob(['(' + workerInterface.toString() + ')(' + factorySource + ');'],
|
||||
{type : 'text/javascript'});
|
||||
|
||||
return window.URL.createObjectURL(blob);
|
||||
|
||||
Vendored
+9
File diff suppressed because one or more lines are too long
@@ -50,7 +50,7 @@
|
||||
</footer>
|
||||
|
||||
<script src="../src/vendor/jquery-1.9.0.min.js" type="text/javascript"></script>
|
||||
<script src="../dist/quagga.js" type="text/javascript"></script>
|
||||
<script src="../dist/quagga.min.js" type="text/javascript"></script>
|
||||
<script src="live_w_locator.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</p>
|
||||
</footer>
|
||||
<script src="../src/vendor/jquery-1.9.0.min.js" type="text/javascript"></script>
|
||||
<script src="../dist/quagga.js" type="text/javascript"></script>
|
||||
<script src="../dist/quagga.min.js" type="text/javascript"></script>
|
||||
<script src="static_images.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+14
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "quagga",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "An advanced barcode-scanner written in JavaScript",
|
||||
"main": "dist/quagga.js",
|
||||
"devDependencies": {
|
||||
@@ -30,6 +30,19 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/serratus/quaggaJS.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/serratus/quaggaJS/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"quagga",
|
||||
"quaggajs",
|
||||
"barcode",
|
||||
"ean",
|
||||
"code128",
|
||||
"code39",
|
||||
"getusermedia",
|
||||
"imageprocessing"
|
||||
],
|
||||
"author": "Christoph Oberhofer <ch.oberhofer@gmail.com>",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ define(function(){
|
||||
controls: false,
|
||||
locate: true,
|
||||
numOfWorkers: 4,
|
||||
scriptName: 'quagga.js',
|
||||
visual: {
|
||||
show: true
|
||||
},
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*
|
||||
<augmentedJS: A javascript library for natural feature tracking>
|
||||
Copyright (C) 2011
|
||||
- Christoph Oberhofer (ar.oberhofer@gmail.com)
|
||||
- Jens Grubert (jg@jensgrubert.de)
|
||||
- Gerhard Reitmayr (reitmayr@icg.tugraz.at)
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* glMatrixAddon.js
|
||||
* Extension to the glMatrix library. The original glMatrix library
|
||||
|
||||
+17
-14
@@ -1,5 +1,6 @@
|
||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
||||
/* global define, vec2, importScripts */
|
||||
/* jshint undef: true, unused: true, browser:true, devel: true, evil: true */
|
||||
/* global define, vec2 */
|
||||
|
||||
|
||||
define(["code_128_reader", "ean_reader", "input_stream", "image_wrapper", "barcode_locator", "barcode_decoder", "frame_grabber", "html_utils", "config", "events", "camera_access", "image_debug"],
|
||||
function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, BarcodeDecoder, FrameGrabber, HtmlUtils, _config, Events, CameraAccess, ImageDebug) {
|
||||
@@ -278,8 +279,13 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
||||
}
|
||||
|
||||
|
||||
function workerInterface(scriptUrl) {
|
||||
importScripts(scriptUrl);
|
||||
function workerInterface(factory) {
|
||||
if (factory) {
|
||||
var Quagga = factory();
|
||||
if (!Quagga) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* jshint ignore:start */
|
||||
var imageWrapper;
|
||||
|
||||
@@ -313,18 +319,15 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
||||
|
||||
function generateWorkerBlob() {
|
||||
var blob,
|
||||
quaggaAbsoluteUrl,
|
||||
scripts = document.getElementsByTagName('script'),
|
||||
regex = new RegExp('\/' + _config.scriptName + '$');
|
||||
factorySource;
|
||||
|
||||
quaggaAbsoluteUrl = Array.prototype.slice.apply(scripts).filter(function(script) {
|
||||
return script.src && script.src.match(regex);
|
||||
}).map(function(script) {
|
||||
return script.src;
|
||||
})[0];
|
||||
/* jshint ignore:start */
|
||||
if (typeof __factorySource__ !== 'undefined') {
|
||||
factorySource = __factorySource__;
|
||||
}
|
||||
/* jshint ignore:end */
|
||||
|
||||
|
||||
blob = new Blob(['(' + workerInterface.toString() + ')("' + quaggaAbsoluteUrl + '");'],
|
||||
blob = new Blob(['(' + workerInterface.toString() + ')(' + factorySource + ');'],
|
||||
{type : 'text/javascript'});
|
||||
|
||||
return window.URL.createObjectURL(blob);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
define(function() {
|
||||
"use strict";
|
||||
|
||||
/* @preserve ASM BEGIN */
|
||||
function Skeletonizer(stdlib, foreign, buffer) {
|
||||
"use asm";
|
||||
|
||||
@@ -197,6 +198,7 @@ define(function() {
|
||||
skeletonize : skeletonize
|
||||
};
|
||||
}
|
||||
/* @preserve ASM END */
|
||||
|
||||
return Skeletonizer;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Idea taken from https://github.com/fpirsch/twin-bcrypt/blob/master/Gearfile.js
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('uglyasm', function() {
|
||||
var code = fs.readFileSync('dist/quagga.js', 'utf-8'),
|
||||
minifiedCode = fs.readFileSync('dist/quagga.min.js', 'utf-8'),
|
||||
commentEnd = '/* @preserve ASM END */',
|
||||
asmStartIdx = code.indexOf('/* @preserve ASM BEGIN */'),
|
||||
asmEndIdx = code.indexOf(commentEnd),
|
||||
asmCode = code.substring(asmStartIdx, asmEndIdx + commentEnd.length),
|
||||
asmFunctionRegex = /function (\w+)\(\w+,\s*\w+,\s*\w+\)\s*\{\s*"use asm";/,
|
||||
asmModule,
|
||||
asmModuleName,
|
||||
asmCodeMinified,
|
||||
asmMinifiedModuleName;
|
||||
|
||||
asmCodeMinified = asmCode
|
||||
.replace(/\s*\/\/.*/g, '') // remove single-line comments
|
||||
.replace(/\s*\/\*[^]*?\*\//g, '') // remove multi-line comments
|
||||
.replace(/\n\s*/g, '') // remove indentation
|
||||
.replace(/ ([+=^|&]|>+|<+) /g, '$1') // remove spaces around operators
|
||||
.replace(/[\r\n/]/g, ''); // remove new lines
|
||||
|
||||
grunt.log.debug(asmCodeMinified);
|
||||
|
||||
asmModule = asmCode.match(asmFunctionRegex);
|
||||
if (!asmModule) {
|
||||
grunt.log.error("No ASM module found");
|
||||
return;
|
||||
}
|
||||
|
||||
asmModuleName = asmModule[1];
|
||||
grunt.log.debug(asmModuleName);
|
||||
|
||||
asmModule = minifiedCode.match(asmFunctionRegex);
|
||||
if (!asmModule) {
|
||||
grunt.log.error("No ASM module found in minified file");
|
||||
return;
|
||||
}
|
||||
|
||||
asmMinifiedModuleName = asmModule[1];
|
||||
grunt.log.debug(asmMinifiedModuleName);
|
||||
|
||||
asmCodeMinified = asmCodeMinified.replace(asmModuleName, asmMinifiedModuleName);
|
||||
|
||||
minifiedCode = minifiedCode.replace(/\/\* @preserve ASM BEGIN \*\/[^]*?\/\* @preserve ASM END \*\//, asmCodeMinified);
|
||||
fs.writeFileSync('dist/quagga.min.js', minifiedCode);
|
||||
grunt.log.ok('dist/quagga.min.js written');
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user