mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-13 05:31:37 +08:00
Improved versions of the examples-pages. Now including the possibility to switch between Code128 and EAN.
This commit is contained in:
Vendored
+8
@@ -6641,6 +6641,11 @@ define('barcode_decoder',["bresenham", "image_debug", 'code_128_reader', 'ean_re
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setReaders: function(readers) {
|
||||||
|
config.readers = readers;
|
||||||
|
_barcodeReaders.length = 0;
|
||||||
|
initReaders();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -7175,6 +7180,9 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
|||||||
isInitialized : function() {
|
isInitialized : function() {
|
||||||
return _initialized;
|
return _initialized;
|
||||||
},
|
},
|
||||||
|
setReaders: function(readers) {
|
||||||
|
_decoder.setReaders(readers);
|
||||||
|
},
|
||||||
canvas : _canvasContainer,
|
canvas : _canvasContainer,
|
||||||
decodeSingle : function(config, resultCallback) {
|
decodeSingle : function(config, resultCallback) {
|
||||||
config.inputStream = {
|
config.inputStream = {
|
||||||
|
|||||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+23
-9
@@ -33,43 +33,57 @@
|
|||||||
margin-left: -640px;
|
margin-left: -640px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* line 15, ../sass/_viewport.scss */
|
/* line 16, ../sass/_viewport.scss */
|
||||||
|
.controls .reader-group {
|
||||||
|
float: right;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* line 22, ../sass/_viewport.scss */
|
||||||
#result_strip {
|
#result_strip {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
border-top: 1px solid #EEE;
|
border-top: 1px solid #EEE;
|
||||||
border-bottom: 1px solid #EEE;
|
border-bottom: 1px solid #EEE;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
overflow: auto;
|
|
||||||
}
|
}
|
||||||
/* line 21, ../sass/_viewport.scss */
|
/* line 28, ../sass/_viewport.scss */
|
||||||
#result_strip ul.thumbnails {
|
#result_strip ul.thumbnails {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
|
width: auto;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
/* line 26, ../sass/_viewport.scss */
|
/* line 37, ../sass/_viewport.scss */
|
||||||
#result_strip ul.thumbnails > li {
|
#result_strip ul.thumbnails > li {
|
||||||
float: left;
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
width: 160px;
|
width: 160px;
|
||||||
}
|
}
|
||||||
/* line 29, ../sass/_viewport.scss */
|
/* line 41, ../sass/_viewport.scss */
|
||||||
#result_strip ul.thumbnails > li .thumbnail {
|
#result_strip ul.thumbnails > li .thumbnail {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
border: 1px dashed #CCC;
|
border: 1px dashed #CCC;
|
||||||
}
|
}
|
||||||
/* line 34, ../sass/_viewport.scss */
|
/* line 46, ../sass/_viewport.scss */
|
||||||
#result_strip ul.thumbnails > li .thumbnail img {
|
#result_strip ul.thumbnails > li .thumbnail img {
|
||||||
max-width: 140px;
|
max-width: 140px;
|
||||||
}
|
}
|
||||||
/* line 38, ../sass/_viewport.scss */
|
/* line 49, ../sass/_viewport.scss */
|
||||||
|
#result_strip ul.thumbnails > li .thumbnail .caption {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
/* line 51, ../sass/_viewport.scss */
|
||||||
#result_strip ul.thumbnails > li .thumbnail .caption h4 {
|
#result_strip ul.thumbnails > li .thumbnail .caption h4 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
/* line 48, ../sass/_viewport.scss */
|
/* line 61, ../sass/_viewport.scss */
|
||||||
#result_strip ul.thumbnails:after {
|
#result_strip ul.thumbnails:after {
|
||||||
content: "";
|
content: "";
|
||||||
display: table;
|
display: table;
|
||||||
|
|||||||
@@ -22,11 +22,18 @@
|
|||||||
<section id="container" class="container">
|
<section id="container" class="container">
|
||||||
<h3>The user's camera</h3>
|
<h3>The user's camera</h3>
|
||||||
<p>If your platform supports the <strong>getUserMedia</strong> API call, you can try the real-time locating and decoding features.
|
<p>If your platform supports the <strong>getUserMedia</strong> API call, you can try the real-time locating and decoding features.
|
||||||
Simply allow the page to access your web-cam and point it to a barcode encoded with <strong>Code128</strong>.
|
Simply allow the page to access your web-cam and point it to a barcode. You can switch between <strong>Code128</strong>
|
||||||
|
and <strong>EAN</strong> to test different scenarios.
|
||||||
It works best if your camera has built-in auto-focus.
|
It works best if your camera has built-in auto-focus.
|
||||||
</p>
|
</p>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button class="next">Start/Continue</button>
|
<fieldset class="reader-group">
|
||||||
|
<label>Code128</label>
|
||||||
|
<input type="radio" name="reader" value="code_128" checked />
|
||||||
|
<label>EAN</label>
|
||||||
|
<input type="radio" name="reader" value="ean" />
|
||||||
|
</fieldset>
|
||||||
|
<br clear="all" />
|
||||||
</div>
|
</div>
|
||||||
<div id="result_strip">
|
<div id="result_strip">
|
||||||
<ul class="thumbnails"></ul>
|
<ul class="thumbnails"></ul>
|
||||||
|
|||||||
@@ -1,28 +1,44 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
|
var App = {
|
||||||
|
init : function() {
|
||||||
Quagga.init({
|
Quagga.init({
|
||||||
inputStream : {
|
inputStream : {
|
||||||
name : "Live",
|
name : "Live",
|
||||||
type : "LiveStream"
|
type : "LiveStream"
|
||||||
},
|
},
|
||||||
decoder : {
|
decoder : {
|
||||||
readers : ['code_128_reader']
|
readers : ["code_128_reader"]
|
||||||
},
|
},
|
||||||
readyFunc : function() {
|
readyFunc : function() {
|
||||||
|
App.attachListeners();
|
||||||
Quagga.start();
|
Quagga.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
attachListeners : function() {
|
||||||
|
$(".controls .reader-group").on("change", "input", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
Quagga.setReaders([e.target.value + "_reader"]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
detachListeners : function() {
|
||||||
|
$(".controls .reader-group").off("change", "input");
|
||||||
|
},
|
||||||
|
lastResult : null
|
||||||
|
};
|
||||||
|
|
||||||
|
App.init();
|
||||||
|
|
||||||
Quagga.onDetected(function(result) {
|
Quagga.onDetected(function(result) {
|
||||||
Quagga.stop();
|
if (App.lastResult !== result) {
|
||||||
|
App.lastResult = result;
|
||||||
var $node = null, canvas = Quagga.canvas.dom.image;
|
var $node = null, canvas = Quagga.canvas.dom.image;
|
||||||
|
|
||||||
$node = $('<li><div class="thumbnail"><div class="imgWrapper"><img /></div><div class="caption"><h4 class="code"></h4></div></div></li>');
|
$node = $('<li><div class="thumbnail"><div class="imgWrapper"><img /></div><div class="caption"><h4 class="code"></h4></div></div></li>');
|
||||||
$node.find("img").attr("src", canvas.toDataURL());
|
$node.find("img").attr("src", canvas.toDataURL());
|
||||||
$node.find("h4.code").html(result);
|
$node.find("h4.code").html(result);
|
||||||
$("#result_strip ul.thumbnails").prepend($node);
|
$("#result_strip ul.thumbnails").prepend($node);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".controls").on("click", "button.next", function(e) {
|
|
||||||
Quagga.start();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
@@ -12,19 +12,31 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
.reader-group {
|
||||||
|
float: right;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#result_strip{
|
#result_strip{
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
border-top: 1px solid #EEE;
|
border-top: 1px solid #EEE;
|
||||||
border-bottom: 1px solid #EEE;
|
border-bottom: 1px solid #EEE;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
overflow: auto;
|
|
||||||
ul.thumbnails{
|
ul.thumbnails{
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
|
width: auto;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
& > li{
|
& > li{
|
||||||
float: left;
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
width: $videoWidth/4;
|
width: $videoWidth/4;
|
||||||
.thumbnail{
|
.thumbnail{
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
@@ -35,6 +47,7 @@
|
|||||||
max-width: $videoWidth/4 - 20px;
|
max-width: $videoWidth/4 - 20px;
|
||||||
}
|
}
|
||||||
.caption{
|
.caption{
|
||||||
|
white-space: normal;
|
||||||
h4{
|
h4{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
|||||||
@@ -24,9 +24,18 @@
|
|||||||
<h3>Working with static images</h3>
|
<h3>Working with static images</h3>
|
||||||
<p>This examples uses static image files as input which are loaded from the server on startup.
|
<p>This examples uses static image files as input which are loaded from the server on startup.
|
||||||
The locating and decoding process takes place inside the browser.
|
The locating and decoding process takes place inside the browser.
|
||||||
Hit the <strong>next</strong> button to try a different image</p>
|
Hit the <strong>next</strong> button to try a different image. You can also switch between
|
||||||
|
two different test-sets. Each of those contains 10 images, demonstrating the capabilities of decoding
|
||||||
|
<strong>Code128</strong> and <strong>EAN</strong> encoded barcodes.
|
||||||
|
</p>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button class="next">Next</button>
|
<button class="next">Next</button>
|
||||||
|
<fieldset class="reader-group">
|
||||||
|
<label>Code128</label>
|
||||||
|
<input type="radio" name="reader" value="code_128" checked />
|
||||||
|
<label>EAN</label>
|
||||||
|
<input type="radio" name="reader" value="ean" />
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div id="result_strip">
|
<div id="result_strip">
|
||||||
<ul class="thumbnails"></ul>
|
<ul class="thumbnails"></ul>
|
||||||
|
|||||||
@@ -1,17 +1,46 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
|
var App = {
|
||||||
|
init: function() {
|
||||||
Quagga.init({
|
Quagga.init({
|
||||||
inputStream: { name: "Test",
|
inputStream: { name: "Test",
|
||||||
type: "ImageStream",
|
type: "ImageStream",
|
||||||
src: "/test/fixtures/code_128/",
|
src: "/test/fixtures/" + App.config.reader + "/",
|
||||||
length: 10
|
length: App.config.length
|
||||||
},
|
},
|
||||||
decoder : {
|
decoder : {
|
||||||
readers : ['code_128_reader']
|
readers : [App.config.reader + "_reader"]
|
||||||
},
|
},
|
||||||
readyFunc : function() {
|
readyFunc : function() {
|
||||||
|
App.attachListeners();
|
||||||
Quagga.start();
|
Quagga.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
config: {
|
||||||
|
reader: "code_128",
|
||||||
|
length: 10
|
||||||
|
},
|
||||||
|
attachListeners: function() {
|
||||||
|
$(".controls").on("click", "button.next", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
Quagga.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".controls .reader-group").on("change", "input", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
App.detachListeners();
|
||||||
|
Quagga.stop();
|
||||||
|
App.config.reader = e.target.value;
|
||||||
|
App.init();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
detachListeners: function() {
|
||||||
|
$(".controls").off("click", "button.next");
|
||||||
|
$(".controls .reader-group").off("change", "input");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
App.init();
|
||||||
|
|
||||||
Quagga.onDetected(function(result) {
|
Quagga.onDetected(function(result) {
|
||||||
var $node = null, canvas = Quagga.canvas.dom.image;
|
var $node = null, canvas = Quagga.canvas.dom.image;
|
||||||
@@ -21,8 +50,4 @@ $(function() {
|
|||||||
$node.find("h4.code").html(result);
|
$node.find("h4.code").html(result);
|
||||||
$("#result_strip ul.thumbnails").prepend($node);
|
$("#result_strip ul.thumbnails").prepend($node);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".controls").on("click", "button.next", function(e) {
|
|
||||||
Quagga.start();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
@@ -238,6 +238,11 @@ define(["bresenham", "image_debug", 'code_128_reader', 'ean_reader'], function(B
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setReaders: function(readers) {
|
||||||
|
config.readers = readers;
|
||||||
|
_barcodeReaders.length = 0;
|
||||||
|
initReaders();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,6 +198,9 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
|||||||
isInitialized : function() {
|
isInitialized : function() {
|
||||||
return _initialized;
|
return _initialized;
|
||||||
},
|
},
|
||||||
|
setReaders: function(readers) {
|
||||||
|
_decoder.setReaders(readers);
|
||||||
|
},
|
||||||
canvas : _canvasContainer,
|
canvas : _canvasContainer,
|
||||||
decodeSingle : function(config, resultCallback) {
|
decodeSingle : function(config, resultCallback) {
|
||||||
config.inputStream = {
|
config.inputStream = {
|
||||||
|
|||||||
Reference in New Issue
Block a user