You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**For a full example, see `/examples` or [this plunkr](http://plnkr.co/aWikiL)**
22
24
25
+
The API is Pretty simple:
26
+
27
+
### QCodeDecoder()
28
+
Constructor. No args. Might be create with or without `new`.
29
+
30
+
```javascript
31
+
var qr =newQCodeDecoder();
32
+
// or
33
+
var qr =QCodeDecoder();
34
+
```
35
+
36
+
This construction lets us be able to chain some methods (although not very necessary - the API is **really** simple).
37
+
38
+
#### ::decodeFromImage(img)
39
+
40
+
Decodes an image from a source provided or an `<img>` element with a `src` attribute set.
41
+
42
+
```javascript
43
+
qr.decodeFromImage(img, function (err, result) {
44
+
if (err) throw err;
45
+
46
+
alert(result);
47
+
});
48
+
```
49
+
50
+
#### ::decodeFromVideo(videoElem, cb, [,once])
51
+
Decodes directly from a video with a well specified `src` attribute
52
+
53
+
```javascript
54
+
QCodeDecoder()
55
+
.decodeFromVideo(document.querySelector('video'), function (err, result) {
56
+
if (err) throw err;
57
+
58
+
alert(result);
59
+
}, true);
60
+
```
61
+
62
+
63
+
#### ::decodeFromCamera(videoElem, cb, [,once])
64
+
Decodes from a videoElement. The optional argument **once** makes the *QCodeDecoder* to only find a QRCode once.
65
+
66
+
```javascript
67
+
qr.decodeFromCamera(videoElem, function (err) {
68
+
if (err) throw err;
69
+
70
+
alert(result);
71
+
});
72
+
```
73
+
74
+
#### ::stop()
75
+
76
+
Stops the current `qr` from searching for a QRCode.
77
+
78
+
23
79
## Messing around
24
80
25
-
For messing around w/ this module and making the example alive, run `npm run start-server` and then go to `http://localhost:8080/examples`
81
+
The proper use of camera APIs and, then, the use of this module, the developer needs to first initiate a webserver for running the examples. I suggest going with [http-server](https://github.com/nodeapps/http-server).
26
82
27
83
## Credits
28
84
29
85
The main decoder methods are from [Lazar Laszlo](http://www.
30
-
lazarsoft.info/). Go check his work!
86
+
lazarsoft.info/), who ported ZXing lib (Apache V2) to JavaScript.
0 commit comments