From fa923c8b21faaa56287cd78fb73d90bba7826ee4 Mon Sep 17 00:00:00 2001 From: Christoph Oberhofer Date: Wed, 3 Sep 2014 22:11:06 +0200 Subject: [PATCH] Update README.md --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index f6c91f1..0567ada 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,48 @@ In order to take full advantage of quaggaJS, the browser needs to support the `g In cases where real-time decoding is not needed, or the platform does not support `getUserMedia` QuaggaJS is also capable to decode image-files. +## Installation +Just clone the repository and include `quagga.min.js` in your project. The code uses [requirejs][requirejs] for dependency management. + +## Usage + +The library exposes the following API + +### quagga.init(config, callback) + +This method initializes the library for a given configuration and a function which is called when the loading-process has finished. The initialization process also requests for camera access if real-time detection is configured. + +### quagga.start() + +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. + +### onDetected(callback) + +Registeres a callback function which is triggered whenever a barcode-pattern has been located and decoded successfully. The callback function is called with the decoded data as the first parameter. + +### 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 decoded data as first parameter. + +## 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. + +```javascript +quagga.decodeSingle({ + readers: [quagga.Reader.Code128Reader], + locate: true, // try to locate the barcode in the image + src: src //'data:image/jpg;base64,' + data +}, function(result){ + console.log(result); +}); +``` [teaser_image]: https://github.com/serratus/quaggaJS/blob/master/doc/img/quaggaJS-code128.png [caniuse_getusermedia]: http://caniuse.com/#feat=stream +[requirejs]: http://requirejs.org/