schmich / instascan Goto Github PK
View Code? Open in Web Editor NEWHTML5 QR code scanner using your webcam
Home Page: https://schmich.github.io/instascan/
License: MIT License
HTML5 QR code scanner using your webcam
Home Page: https://schmich.github.io/instascan/
License: MIT License
See #45.
webrtc-adapter
should be a peer dependency, not a direct dependency, of this libraryinstascan.min.js
as well as adapter.min.js
webrtc-adapter
included)?npm install --save instascan webrtc-adapter
scanner.scan()
opts.continuous
.scan
event path, should respect captureImage
refractoryPeriod
scan
event, but allows for better controlThe back camera of my Xiaomi Redmi 4 Pro phone shows only a black image.
The front camera instead works fine.
It seems to be a bug with this library because other javascript scanners like quaggaJS work fine with both cameras.
This bug is in the demo page too.
js
, css
, .../
public/
index.html
css/
img/
js/
ATTRIBUTION
LICENSE
{ video: { facingMode: "user" } }
{ video: { facingMode: { exact: "environment" } } }
If you control QR generation:
Scanning:
getCameras
before our first call to webkitGetUserMedia
, so the cameras do not enumerate properlyHello I need to make this to be able to detect multiple QR codes at the same time. Is this a possibility?
If scanner is stopped and scanner.start
is called while tab is not focused and backgroundScan is false
, the scanner still starts. Instead, it should transition to the inactive
state.
GET
, POST
, PUT
, PATCH
, etc.%r
: raw content%s
: scanned content%i
: base64-encoded image dataContent-Type
headerMVP:
POST
By default, backgroundScan
should be true
to avoid potentially confusing behavior (see #43). By making the user explicitly set backgroundScan
to false
, they should understand why the preview video disappears and reappears.
.*
, transform: http://foo.com?q=$0
$1
, $2
, ... capture groupssnackbar
opts = { captureImage: { format: "png", quality: 0.9 } }
When using the library inside a AMD (requireJS) app I get an error probably related with the loading of lodash module. There are plans to package the library as AMD or UMD? There is a workaround for this issue?
Uncaught TypeError: _.forEach is not a function
at Object.init (instascan.js:7995)
at Stamp (instascan.js:26856)
at Function.create (instascan.js:27056)
at Scanner._createStateMachine (instascan.js:30311)
at new Scanner (instascan.js:30150)
at scanQR (play.js:866)
at HTMLFieldSetElement. (play.js:528)
at HTMLFieldSetElement.dispatch (jquery-2.1.4.min.js:3)
at HTMLFieldSetElement.r.handle (jquery-2.1.4.min.js:3)
active
class to video element.inactive
class to video element.npm install instascan
and var Instascan = require('instascan');
instascan.min.js
from release zipScan history entries should have buttons to open links in new tab. Button should be to the left of the copy button
It would be helpful if this was compiled to ES5. Webpack/Babel isn't able to compile it when added as a dependency to package.json
.
let scanner = new Instascan.Scanner();
scanner.addListener('scan', function (content, image) {
console.log(content);
});
Instascan.Camera.getCameras().then(function (cameras) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error('No cameras found.');
}
});
When running this for the first time on a domain that the user doesn't trust yet, the cameras
from getCameras
have null
names because the user hasn't yet allowed access to the camera.
When scanner.start
is called, the user is prompted. When the user accepts, the app has to call getCameras
again to actually get the names.
This should be at least called out in the documentation if not fixed with a more straightforward API.
Here are my HTML.
<div id="video_container" style="align-items:center;display:flex;height:100%;justify-content:center;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:2.5px;overflow:hidden;">
<video id="video" width="50%" autoplay loop muted preload></video>
</div>
I am using the example codes.
let scanner = new Instascan.Scanner({ video: document.getElementById('video') });
scanner.addListener('scan', function (content) {
console.log(content);
});
Instascan.Camera.getCameras().then(function (cameras) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error('No cameras found.');
}
}).catch(function (e) {
console.error(e);
});
Here is animated .gif of the problem. After I change tab (twice) the <video>
gone although the DOM is still the same.
The screen shot of the <video>
when it is gone.
instascan.js:26271 Uncaught RangeError:
Failed to execute 'getImageData' on 'CanvasRenderingContext2D':
Out of memory at ImageData creationanalyze
@ instascan.js:26271_analyze
@ instascan.js:26156_scan
@ instascan.js:26207(anonymous function)
@ instascan.js:26198
>>>> var data = this.canvasContext.getImageData(0, 0, this.sensorWidth, this.sensorHeight).data;
for (var i = 0, j = 0; i < data.length; i += 4, j++) {
ZXing.HEAPU8[this.imageBuffer + j] = data[i];
}
monitor
to video
or something similarscanner.start(...)
scanner.stop()
stop
call)Is there a way yo have a mark on the canvas to show the user a frame has been captured and an analyse is in progress?
Or better show like in a native app some dots over the recognized points ?
http://foo.com/?q={scan}
mirror
setting doesn't work well (might be phone-dependent)Uncaught SyntaxError: Unexpected end of input
app.js:11 Uncaught ReferenceError: Instascan is not defined
at Ue.mounted (app.js:11)
at we (vue.min.js:6)
at Ue.e._mount (vue.min.js:6)
at Ue.$mount (vue.min.js:8)
at Ue.$mount (vue.min.js:8)
at Ue.Re.e._init (vue.min.js:6)
at new Ue (vue.min.js:6)
at app.js:1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.