first commit
22
.gitattributes
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Custom for Visual Studio
|
||||||
|
*.cs diff=csharp
|
||||||
|
*.sln merge=union
|
||||||
|
*.csproj merge=union
|
||||||
|
*.vbproj merge=union
|
||||||
|
*.fsproj merge=union
|
||||||
|
*.dbproj merge=union
|
||||||
|
|
||||||
|
# Standard to msysgit
|
||||||
|
*.doc diff=astextplain
|
||||||
|
*.DOC diff=astextplain
|
||||||
|
*.docx diff=astextplain
|
||||||
|
*.DOCX diff=astextplain
|
||||||
|
*.dot diff=astextplain
|
||||||
|
*.DOT diff=astextplain
|
||||||
|
*.pdf diff=astextplain
|
||||||
|
*.PDF diff=astextplain
|
||||||
|
*.rtf diff=astextplain
|
||||||
|
*.RTF diff=astextplain
|
||||||
215
.gitignore
vendored
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
#################
|
||||||
|
## Eclipse
|
||||||
|
#################
|
||||||
|
|
||||||
|
*.pydevproject
|
||||||
|
.project
|
||||||
|
.metadata
|
||||||
|
bin/
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# CDT-specific
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# PDT-specific
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
|
||||||
|
#################
|
||||||
|
## Visual Studio
|
||||||
|
#################
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
build/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.log
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
*.pubxml
|
||||||
|
|
||||||
|
# NuGet Packages Directory
|
||||||
|
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||||
|
#packages/
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
sql/
|
||||||
|
*.Cache
|
||||||
|
ClientBin/
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
App_Data/*.mdf
|
||||||
|
App_Data/*.ldf
|
||||||
|
|
||||||
|
#############
|
||||||
|
## Windows detritus
|
||||||
|
#############
|
||||||
|
|
||||||
|
# Windows image file caches
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Mac crap
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
## Python
|
||||||
|
#############
|
||||||
|
|
||||||
|
*.py[co]
|
||||||
|
|
||||||
|
# Packages
|
||||||
|
*.egg
|
||||||
|
*.egg-info
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
eggs/
|
||||||
|
parts/
|
||||||
|
var/
|
||||||
|
sdist/
|
||||||
|
develop-eggs/
|
||||||
|
.installed.cfg
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
.coverage
|
||||||
|
.tox
|
||||||
|
|
||||||
|
#Translations
|
||||||
|
*.mo
|
||||||
|
|
||||||
|
#Mr Developer
|
||||||
|
.mr.developer.cfg
|
||||||
2107
DecoderWorker.js
Normal file
352
JOB.js
Normal file
@@ -0,0 +1,352 @@
|
|||||||
|
/**
|
||||||
|
* CallBacks:
|
||||||
|
* __________________________________________________________________________________
|
||||||
|
* All the callback function should have one parameter:
|
||||||
|
* function(result){};
|
||||||
|
* And the result parameter will contain an array of objects that look like JOB.
|
||||||
|
* result = [{Format: the barcode type, Value: the value of the barcode}];
|
||||||
|
* __________________________________________________________________________________
|
||||||
|
*
|
||||||
|
* You can use either the set functions or just access the properties directly to set callback or
|
||||||
|
* other properties. Just always remember to call Init() before starting to decode something never mess
|
||||||
|
* around with the SupportedFormats property.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
JOB = {
|
||||||
|
Config : {
|
||||||
|
// Set to false if the decoder should look for one barcode and then stop. Increases performance.
|
||||||
|
Multiple : true,
|
||||||
|
|
||||||
|
// The formats that the decoder will look for.
|
||||||
|
DecodeFormats : ["Code128","Code93","Code39","EAN-13", "2Of5", "Inter2Of5", "Codabar"],
|
||||||
|
|
||||||
|
// ForceUnique just must makes sure that the callback function isn't repeatedly called
|
||||||
|
// with the same barcode. Especially in the case of a video stream.
|
||||||
|
ForceUnique: true,
|
||||||
|
|
||||||
|
// Set to true if information about the localization should be recieved from the worker.
|
||||||
|
LocalizationFeedback: false,
|
||||||
|
|
||||||
|
// Set to true if checking orientation of the image should be skipped.
|
||||||
|
// Checking orientation takes a bit of time for larger images, so if
|
||||||
|
// you are sure that the image orientation is 1 you should skip it.
|
||||||
|
SkipOrientation : false
|
||||||
|
},
|
||||||
|
SupportedFormats : ["Code128","Code93","Code39","EAN-13", "2Of5", "Inter2Of5", "Codabar"],// Don't touch.
|
||||||
|
ScanCanvas : null, // Don't touch the canvas either.
|
||||||
|
ScanContext : null,
|
||||||
|
SquashCanvas : document.createElement("canvas"),
|
||||||
|
ImageCallback : null, // Callback for the decoding of an image.
|
||||||
|
StreamCallback : null, // Callback for the decoding of a video.
|
||||||
|
LocalizationCallback : null, // Callback for localization.
|
||||||
|
Stream : null, // The actual video.
|
||||||
|
DecodeStreamActive : false, // Will be set to false when StopStreamDecode() is called.
|
||||||
|
Decoded : [], // Used to enfore the ForceUnique property.
|
||||||
|
DecoderWorker : new Worker("DecoderWorker.js"),
|
||||||
|
OrientationCallback : null,
|
||||||
|
// Always call the Init().
|
||||||
|
Init : function() {
|
||||||
|
JOB.ScanCanvas = JOB.FixCanvas(document.createElement("canvas"));
|
||||||
|
JOB.ScanCanvas.width = 640;
|
||||||
|
JOB.ScanCanvas.height = 480;
|
||||||
|
JOB.ScanContext = JOB.ScanCanvas.getContext("2d");
|
||||||
|
var script = document.createElement('script');
|
||||||
|
script.src = "exif.js";
|
||||||
|
script.type = 'text/javascript';
|
||||||
|
document.getElementsByTagName('head').item(0).appendChild(script);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Value should be true or false.
|
||||||
|
SetRotationSkip : function(value) {
|
||||||
|
JOB.Config.SkipOrientation = value;
|
||||||
|
},
|
||||||
|
// Sets the callback function for the image decoding.
|
||||||
|
SetImageCallback : function(callBack) {
|
||||||
|
JOB.ImageCallback = callBack;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Sets the callback function for the video decoding.
|
||||||
|
SetStreamCallback : function(callBack) {
|
||||||
|
JOB.StreamCallback = callBack;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Sets callback for localization, the callback function should take one argument.
|
||||||
|
// This will be an array with objects with format.
|
||||||
|
// {x, y, width, height}
|
||||||
|
// This represents a localization rectangle.
|
||||||
|
// The rectangle comes from a 320, 240 area i.e the search canvas.
|
||||||
|
SetLocalizationCallback : function(callBack) {
|
||||||
|
JOB.LocalizationCallback = callBack;
|
||||||
|
JOB.Config.LocalizationFeedback = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Set to true if LocalizationCallback is set and you would like to
|
||||||
|
// receive the feedback or false if
|
||||||
|
SwitchLocalizationFeedback : function(bool) {
|
||||||
|
JOB.Config.LocalizationFeedback = bool;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Switches for changing the Multiple property.
|
||||||
|
DecodeSingleBarcode : function() {
|
||||||
|
JOB.Config.Multiple = false;
|
||||||
|
},
|
||||||
|
DecodeMultiple : function() {
|
||||||
|
JOB.Config.Multiple = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Sets the formats to decode, formats should be an array of a subset of the supported formats.
|
||||||
|
SetDecodeFormats : function(formats) {
|
||||||
|
JOB.Config.DecodeFormats = [];
|
||||||
|
for(var i = 0; i < formats.length; i++) {
|
||||||
|
if(JOB.SupportedFormats.indexOf(formats[i]) != -1) {
|
||||||
|
JOB.Config.DecodeFormats.push(formats[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(JOB.Config.DecodeFormats.length == 0) {
|
||||||
|
JOB.Config.DecodeFormats = JOB.SupportedFormats.slice();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Removes a list of formats from the formats to decode.
|
||||||
|
SkipFormats : function(formats) {
|
||||||
|
for(var i = 0; i < formats.length; i++) {
|
||||||
|
var index = JOB.Config.DecodeFormats.indexOf(formats[i]);
|
||||||
|
if(index >= 0) {
|
||||||
|
JOB.Config.DecodeFormats.splice(index,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Adds a list of formats to the formats to decode.
|
||||||
|
AddFormats : function(formats) {
|
||||||
|
for(var i = 0; i < formats.length; i++) {
|
||||||
|
if(JOB.SupportedFormats.indexOf(formats[i]) != -1) {
|
||||||
|
if(JOB.Config.DecodeFormats.indexOf(formats[i]) == -1) {
|
||||||
|
JOB.Config.DecodeFormats.push(formats[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// The callback function for image decoding used internally by JOB.
|
||||||
|
JOBImageCallback : function(e) {
|
||||||
|
if(e.data.success == "localization") {
|
||||||
|
if(JOB.Config.LocalizationFeedback) {
|
||||||
|
JOB.LocalizationCallback(e.data.result);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(e.data.success == "orientationData") {
|
||||||
|
JOB.OrientationCallback(e.data.result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var filteredData = [];
|
||||||
|
for(var i = 0; i < e.data.result.length; i++) {
|
||||||
|
if(JOB.Decoded.indexOf(e.data.result[i].Value) == -1 || JOB.Config.ForceUnique == false) {
|
||||||
|
filteredData.push(e.data.result[i]);
|
||||||
|
if(JOB.Config.ForceUnique) JOB.Decoded.push(e.data.result[i].Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JOB.ImageCallback(filteredData);
|
||||||
|
JOB.Decoded = [];
|
||||||
|
},
|
||||||
|
|
||||||
|
// The callback function for stream decoding used internally by JOB.
|
||||||
|
JOBStreamCallback : function(e) {
|
||||||
|
if(e.data.success == "localization") {
|
||||||
|
if(JOB.Config.LocalizationFeedback) {
|
||||||
|
JOB.LocalizationCallback(e.data.result);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(e.data.success && JOB.DecodeStreamActive) {
|
||||||
|
var filteredData = [];
|
||||||
|
for(var i = 0; i < e.data.result; i++) {
|
||||||
|
if(JOB.Decoded.indexOf(e.data.result[i].Value) == -1 || JOB.ForceUnique == false) {
|
||||||
|
filteredData.push(e.data.result[i]);
|
||||||
|
if(JOB.ForceUnique) JOB.Decoded.push(e.data.result[i].Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(filteredData.length > 0) {
|
||||||
|
JOB.StreamCallback(filteredData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(JOB.DecodeStreamActive) {
|
||||||
|
JOB.ScanContext.drawImage(JOB.Stream,0,0,JOB.ScanCanvas.width,JOB.ScanCanvas.height);
|
||||||
|
JOB.DecoderWorker.postMessage({
|
||||||
|
scan : JOB.ScanContext.getImageData(0,0,JOB.ScanCanvas.width,JOB.ScanCanvas.height).data,
|
||||||
|
scanWidth : JOB.ScanCanvas.width,
|
||||||
|
scanHeight : JOB.ScanCanvas.height,
|
||||||
|
multiple : JOB.Config.Multiple,
|
||||||
|
decodeFormats : JOB.Config.DecodeFormats,
|
||||||
|
cmd : "normal",
|
||||||
|
rotation : 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!JOB.DecodeStreamActive) {
|
||||||
|
JOB.Decoded = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// The image decoding function, image is a data source for an image or an image element.
|
||||||
|
DecodeImage : function(image) {
|
||||||
|
if(image instanceof Image || image instanceof HTMLImageElement)
|
||||||
|
{
|
||||||
|
image.exifdata = false;
|
||||||
|
if(image.complete) {
|
||||||
|
if(JOB.Config.SkipOrientation) {
|
||||||
|
JOB.JOBDecodeImage(image,1,"");
|
||||||
|
} else {
|
||||||
|
EXIF.getData(image, function(exifImage) {
|
||||||
|
var orientation = EXIF.getTag(exifImage,"Orientation");
|
||||||
|
var sceneType = EXIF.getTag(exifImage,"SceneCaptureType");
|
||||||
|
if(typeof orientation != 'number') orientation = 1;
|
||||||
|
JOB.JOBDecodeImage(exifImage,orientation,sceneType);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var img = new Image();
|
||||||
|
img.onload = function() {
|
||||||
|
if(JOB.Config.SkipOrientation) {
|
||||||
|
JOB.JOBDecodeImage(img,1,"");
|
||||||
|
} else {
|
||||||
|
EXIF.getData(this, function(exifImage) {
|
||||||
|
var orientation = EXIF.getTag(exifImage,"Orientation");
|
||||||
|
var sceneType = EXIF.getTag(exifImage,"SceneCaptureType");
|
||||||
|
if(typeof orientation != 'number') orientation = 1;
|
||||||
|
JOB.JOBDecodeImage(exifImage,orientation,sceneType);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
img.src = image.src;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var img = new Image();
|
||||||
|
img.onload = function() {
|
||||||
|
if(JOB.Config.SkipOrientation) {
|
||||||
|
JOB.JOBDecodeImage(img,1,"");
|
||||||
|
} else {
|
||||||
|
EXIF.getData(this, function(exifImage) {
|
||||||
|
var orientation = EXIF.getTag(exifImage,"Orientation");
|
||||||
|
var sceneType = EXIF.getTag(exifImage,"SceneCaptureType");
|
||||||
|
if(typeof orientation != 'number') orientation = 1;
|
||||||
|
JOB.JOBDecodeImage(exifImage,orientation,sceneType);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
img.src = image;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Starts the decoding of a stream, the stream is a video not a blob i.e it's an element.
|
||||||
|
DecodeStream : function(stream) {
|
||||||
|
JOB.Stream = stream;
|
||||||
|
JOB.DecodeStreamActive = true;
|
||||||
|
JOB.DecoderWorker.onmessage = JOB.JOBStreamCallback;
|
||||||
|
JOB.ScanContext.drawImage(stream,0,0,JOB.ScanCanvas.width,JOB.ScanCanvas.height);
|
||||||
|
JOB.DecoderWorker.postMessage({
|
||||||
|
scan : JOB.ScanContext.getImageData(0,0,JOB.ScanCanvas.width,JOB.ScanCanvas.height).data,
|
||||||
|
scanWidth : JOB.ScanCanvas.width,
|
||||||
|
scanHeight : JOB.ScanCanvas.height,
|
||||||
|
multiple : JOB.Config.Multiple,
|
||||||
|
decodeFormats : JOB.Config.DecodeFormats,
|
||||||
|
cmd : "normal",
|
||||||
|
rotation : 1,
|
||||||
|
});
|
||||||
|
var onmessage = JOB.DecoderWorker.onmessage;
|
||||||
|
JOB.DecoderWorker.onmessage = function (data) {
|
||||||
|
onmessage(data);
|
||||||
|
if (data.data.success !== 'localization') {
|
||||||
|
console.log('onmessage', data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
// Stops the decoding of a stream.
|
||||||
|
StopStreamDecode : function() {
|
||||||
|
JOB.DecodeStreamActive = false;
|
||||||
|
JOB.Decoded = [];
|
||||||
|
},
|
||||||
|
|
||||||
|
JOBDecodeImage : function (image,orientation,sceneCaptureType) {
|
||||||
|
if(orientation == 8 || orientation == 6) {
|
||||||
|
if(sceneCaptureType == "Landscape" && image.width > image.height) {
|
||||||
|
orientation = 1;
|
||||||
|
JOB.ScanCanvas.width = 640;
|
||||||
|
JOB.ScanCanvas.height = 480;
|
||||||
|
} else {
|
||||||
|
JOB.ScanCanvas.width = 480;
|
||||||
|
JOB.ScanCanvas.height = 640;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
JOB.ScanCanvas.width = 640;
|
||||||
|
JOB.ScanCanvas.height = 480;
|
||||||
|
}
|
||||||
|
JOB.DecoderWorker.onmessage = JOB.JOBImageCallback;
|
||||||
|
JOB.ScanContext.drawImage(image,0,0,JOB.ScanCanvas.width,JOB.ScanCanvas.height);
|
||||||
|
JOB.Orientation = orientation;
|
||||||
|
JOB.DecoderWorker.postMessage({
|
||||||
|
scan : JOB.ScanContext.getImageData(0,0,JOB.ScanCanvas.width,JOB.ScanCanvas.height).data,
|
||||||
|
scanWidth : JOB.ScanCanvas.width,
|
||||||
|
scanHeight : JOB.ScanCanvas.height,
|
||||||
|
multiple : JOB.Config.Multiple,
|
||||||
|
decodeFormats : JOB.Config.DecodeFormats,
|
||||||
|
cmd : "normal",
|
||||||
|
rotation : orientation,
|
||||||
|
postOrientation : JOB.PostOrientation
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
DetectVerticalSquash : function (img) {
|
||||||
|
var ih = img.naturalHeight;
|
||||||
|
var canvas = JOB.SquashCanvas;
|
||||||
|
canvas.width = 1;
|
||||||
|
canvas.height = ih;
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
ctx.drawImage(img, 0, 0);
|
||||||
|
try {
|
||||||
|
var data = ctx.getImageData(0, 0, 1, ih).data;
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Cannot check verticalSquash: CORS?");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var sy = 0;
|
||||||
|
var ey = ih;
|
||||||
|
var py = ih;
|
||||||
|
while (py > sy) {
|
||||||
|
var alpha = data[(py - 1) * 4 + 3];
|
||||||
|
if (alpha === 0) {
|
||||||
|
ey = py;
|
||||||
|
} else {
|
||||||
|
sy = py;
|
||||||
|
}
|
||||||
|
py = (ey + sy) >> 1;
|
||||||
|
}
|
||||||
|
var ratio = (py / ih);
|
||||||
|
return (ratio===0)?1:ratio;
|
||||||
|
},
|
||||||
|
|
||||||
|
FixCanvas : function (canvas)
|
||||||
|
{
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
var drawImage = ctx.drawImage;
|
||||||
|
ctx.drawImage = function(img, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||||
|
{
|
||||||
|
var vertSquashRatio = 1;
|
||||||
|
if (!!img && img.nodeName == 'IMG')
|
||||||
|
{
|
||||||
|
vertSquashRatio = JOB.DetectVerticalSquash(img);
|
||||||
|
sw || (sw = img.naturalWidth);
|
||||||
|
sh || (sh = img.naturalHeight);
|
||||||
|
}
|
||||||
|
if (arguments.length == 9)
|
||||||
|
drawImage.call(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
|
||||||
|
else if (typeof sw != 'undefined')
|
||||||
|
drawImage.call(ctx, img, sx, sy, sw, sh / vertSquashRatio);
|
||||||
|
else
|
||||||
|
drawImage.call(ctx, img, sx, sy);
|
||||||
|
};
|
||||||
|
return canvas;
|
||||||
|
}
|
||||||
|
};
|
||||||
24
README.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
BarcodeReader
|
||||||
|
=============
|
||||||
|
|
||||||
|
BarcodeReader is a barcode reader for Code128, Code93, Code39, Standard/Industrial 2 of 5,
|
||||||
|
Interleaved 2 of 5, Codabar and EAN-13 barcodes in javascript.
|
||||||
|
Supports multiple barcodes in one image and detects what type of barcodes there are.
|
||||||
|
|
||||||
|
It seems that the issue with smartphones might have been one of exif orientation tags so there's a fix in BarcodeReader now and also a fix for some kind of downsampling issue for iOS.
|
||||||
|
|
||||||
|
***
|
||||||
|
If you like and/or use this project for commercial purposes consider donating to support my work.
|
||||||
|
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G5G3LGA8QRA6S"><img src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" alt="PayPal - The safer, easier way to pay online!" /></a>
|
||||||
|
***
|
||||||
|
|
||||||
|
Version 1.6 is up with a completely reworked localization process and also added a BarcodeReader object to facilitate more ease of use. Just reference BarcodeReader.js, always execute a call to BarcodeReader.Init() in the beginning and then for decoding of images set callback function using BarcodeReader.SetImageCallback(callback) and then call BarcodeReader.DecodeImage(img). Also added functionality in BarcodeReader to decode a video stream for use with getUserMedia, which was the original idea. Hopefully this localization will be a significant improvement and I will in the (hopefully) near future do a rework of the decoding algorithm to make it a bit faster and more accurate.
|
||||||
|
|
||||||
|
## Change Log
|
||||||
|
|
||||||
|
### v1.6.1
|
||||||
|
|
||||||
|
- Added video support to the jQuery plugin
|
||||||
|
- Fire event when barcode is decoded
|
||||||
|
- Refactored jQuery elements allowing support for your own
|
||||||
|
- Flipped video to make it easier to position the barcode
|
||||||
BIN
Sample-images/001.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
Sample-images/03.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
Sample-images/04.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
Sample-images/05.jpg
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
Sample-images/06 (2).jpg
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
Sample-images/06.jpg
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
Sample-images/07 (2).jpg
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
Sample-images/07.jpg
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
Sample-images/08 (2).jpg
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
Sample-images/08.jpg
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
Sample-images/1 (2).JPG
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
Sample-images/1.gif
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
Sample-images/1.jpg
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
Sample-images/10 (2).JPG
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
Sample-images/10.jpg
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
Sample-images/11.jpg
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
Sample-images/12 (2).jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Sample-images/1224279904-1.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
Sample-images/13 (2).jpg
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
Sample-images/13 (3).jpg
Normal file
|
After Width: | Height: | Size: 114 KiB |
BIN
Sample-images/13 (4).jpg
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Sample-images/13.jpg
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
Sample-images/136253222790411.gif
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
Sample-images/136253222790411.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
Sample-images/13_barcode11.gif
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
Sample-images/14 (2).jpg
Normal file
|
After Width: | Height: | Size: 115 KiB |
BIN
Sample-images/14.jpg
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
Sample-images/15 (2).JPG
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
Sample-images/15 (3).jpg
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Sample-images/15.jpg
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
Sample-images/16.jpg
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
Sample-images/17.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Sample-images/1D2D.jpg
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
Sample-images/2.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
Sample-images/2.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
Sample-images/20 (2).JPG
Normal file
|
After Width: | Height: | Size: 149 KiB |
BIN
Sample-images/20.jpg
Normal file
|
After Width: | Height: | Size: 99 KiB |
BIN
Sample-images/20.png
Normal file
|
After Width: | Height: | Size: 181 KiB |
BIN
Sample-images/21 (2).jpg
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Sample-images/21.jpg
Normal file
|
After Width: | Height: | Size: 114 KiB |
BIN
Sample-images/23.JPG
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
Sample-images/24.JPG
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
Sample-images/24.png
Normal file
|
After Width: | Height: | Size: 184 KiB |
BIN
Sample-images/25.jpg
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
Sample-images/26.jpg
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
Sample-images/27.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
Sample-images/28.jpg
Normal file
|
After Width: | Height: | Size: 115 KiB |
BIN
Sample-images/2of5-1.gif
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
Sample-images/2of5.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Sample-images/30.jpg
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
Sample-images/3037044282_c6396bc09a.jpg
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
Sample-images/31 (2).jpg
Normal file
|
After Width: | Height: | Size: 97 KiB |
BIN
Sample-images/31.jpg
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
Sample-images/32.jpg
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
Sample-images/33.jpg
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
Sample-images/33.png
Normal file
|
After Width: | Height: | Size: 183 KiB |
BIN
Sample-images/34.jpg
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
Sample-images/37.jpg
Normal file
|
After Width: | Height: | Size: 123 KiB |
BIN
Sample-images/38.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
Sample-images/39.jpg
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
Sample-images/4.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Sample-images/40.jpg
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
Sample-images/5.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
Sample-images/7 (2).JPG
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
Sample-images/7.jpg
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
Sample-images/7355ae1b-12eb-4e70-a650-f659.JPG
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Sample-images/7784075_orig.gif
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
Sample-images/8.jpg
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
Sample-images/800px-Film-interleaved-barcode.jpg
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
Sample-images/ALPHA.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
Sample-images/BarSampling.gif
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
Sample-images/Code-128-3.GIF
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
Sample-images/Code128-C.bmp
Normal file
|
After Width: | Height: | Size: 301 KiB |
BIN
Sample-images/Code128-warped.bmp
Normal file
|
After Width: | Height: | Size: 301 KiB |
BIN
Sample-images/Code128_test.jpg
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
Sample-images/Code39/03.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
Sample-images/Code39/06.jpg
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
Sample-images/Code39/07.jpg
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
Sample-images/Code39/08.jpg
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
Sample-images/Code39/1.gif
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
Sample-images/Code39/10.jpg
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
Sample-images/Code39/11.jpg
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
Sample-images/Code39/12.jpg
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
Sample-images/Code39/13.jpg
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
Sample-images/Code39/14.jpg
Normal file
|
After Width: | Height: | Size: 115 KiB |
BIN
Sample-images/Code39/2.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
Sample-images/Code39/6305.Clipboard01.jpg
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
Sample-images/Code39/GSA 2-Line Barcode+Border.JPG
Normal file
|
After Width: | Height: | Size: 456 KiB |
BIN
Sample-images/Code39/image002.jpg
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Sample-images/Code39/shipping_label_2d_barcode.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
Sample-images/Code93-C.bmp
Normal file
|
After Width: | Height: | Size: 591 KiB |
BIN
Sample-images/EAN-13/1 (2).JPG
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
Sample-images/EAN-13/1.jpg
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
Sample-images/EAN-13/10.JPG
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
Sample-images/EAN-13/12.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |