Skip to content

QR and barcode scanner using HTML and Javascript | Minhaz’s Blog #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
utterances-bot opened this issue Jun 15, 2021 · 33 comments
Open

Comments

@utterances-bot
Copy link

QR and barcode scanner using HTML and Javascript | Minhaz’s Blog

The little QR code scanning library I have been maintaining since 2015 has been getting more attention recently. And with power came responsibilities, bugs, and feature requests. Some of the key features requested by developers were more reliable scanning and the ability to scan different types of bar codes. With version 2.0.0 onwards developers can scan different types of 1D codes (bar codes) and 2D codes (like QR codes or AZTEC). This article lists out everything new in version 2.x.x. I’ll also list out the new APIs and capabilities that developers can use to integrate a more powerful code scanning capability to their web pages or apps.

https://blog.minhazav.dev/QR-and-barcode-scanner-using-html-and-javascript/

Repository owner deleted a comment from Vikas-jk Jul 6, 2021
Copy link

Hello,

is there a way to use the barcode scanner without ssl ?
I will test under windows with xampp.

Your sincerly

Stephan

@mebjas
Copy link
Owner

mebjas commented Oct 25, 2021

@qwertz1958

is there a way to use the barcode scanner without ssl ?

The browsers don't support showing camera feed without SSL. It should work with localhost though.

Copy link

I tested this code and it only scan qr code, but not for barcode 39 and 128. Should I load barcode library or just this script is enough?

<script src="https://unpkg.com/html5-qrcode" type="text/javascript"></script>

Repository owner deleted a comment from Anvilewis1 Nov 5, 2021
Copy link

hello, i need helpp, i dont get any result back when it's scanned, also when im uploading image, but when i try in this demo website it's work fine, but not in my code/..

Copy link

Sorry, I'm being stupid. I put the <script> tag at the bottom of my html page and put the <div> in within the page <body>. But I'm not sure where to put the Initialize script.

@mebjas
Copy link
Owner

mebjas commented Nov 21, 2021

@Bryan-snw is there a place we can review your code?
@Blattinum

But I'm not sure where to put the Initialize script.

Put this after the <script> i.e.

<div id="reader" width="600px"></div>
<!-- rest of your code -->

<!-- include the library -->
<script src="https://unpkg.com/html5-qrcode" type="text/javascript">
<script type="text/javascript">
/** Initialisation code comes here */
</script>

Copy link

gdolenc commented Nov 22, 2021

I am testing on iPhone, after scanning nothing happens? What should happen in demo? Should there be an alert about the info scanned or what?

Copy link

Question - Run npm run-script build to build JavaScript output. The output JavaScript distribution is built to /dist/html5-qrcode.min.js. If you are developing on Windows OS, run npm run-script build-windows.

I am trying to build. Since i am working on windows, i tried the following command npm run-script build-windows. Now I am getting the following error:
'scripts\build-windows.sh' is not recognized as an internal or external command,
operable program or batch file.

Repository owner deleted a comment from Anvilewis1 Feb 7, 2022
Copy link

i tried scanning a UPC-A code but it does not read the barcode. i have tested QR codes and they work. any reason why the UPC-A wont work? the barcode was printed using a Zebra barcode printer.

Copy link

lemoon2 commented Mar 20, 2022

How can I change the zoom of camera in js?
Please help me!

Copy link

Im using this module for my project. its working fine with every Bar-Code. which length is smaller than 12 characters only work fine. but when I use industry standard Bar-Code of 19 characters nothing will happen.

Copy link

Hello Minhaz!

Congrats! This plugin works well, easy install and usage and very fast, i love it! Take all my appreciation!

But i have a question :] :
my code detects that someone is using a mobile phone, in this case is it possible to set the plugin to use the back camera by default? (I can't really imagine a scenario where someone would use the front camera on a mobile phone to scan barcode :> )

BR,
David

@dancsdavid
Copy link

I am testing on iPhone, after scanning nothing happens? What should happen in demo? Should there be an alert about the info scanned or what?

see the console tab in developer tools or put this code to the souce:
`$(document).ready(function() {
let last = '';
function onScanSuccess(decodedText, decodedResult) {
if(last !== decodedText) {
last = decodedText;
alert(decodedText);
}
}

var html5QrcodeScanner = new Html5QrcodeScanner(
    "qr-reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);

});`

Copy link

Using the demo embedded here on my iphone X its unable to read some of the barcodes on my laptop screen from the supported codes section including UPC_A and UPC_E. It does work with QR codes and some other barcodes on that page. Is that expected for the demo? Would it work for UPC_A UPC_E in a full implementation?

Thanks

Copy link

Same here - not able to scan UPCs on iOS or macOS. Seems to work on Chrome on Android.

Copy link

I implemented it in my webapp running it on safari iPhone X I find that it doesnt work with UPC_A (the label used for food and retail products in my country (canada). Tested on physical products with UPC_A label as well as online generated UPC_A label https://barcode.tec-it.com/en/UPCA?data=72527273070

A note aswell, the example UPC_A included in this page does not look the same as UPC_A 's i find on physical products and generated online

Copy link

I have implemented locally. But After giving camera permission. Not showing list of camera in select Camera. So please let me know how can i resolve this?

Copy link

hello master please when i scan barcode
the value not appear
please give the all code same the demo in this page please 🙏

Copy link

Hello,
Can i use barcode scanner device instead of camera using this library?
I'm building a website where I'll use my barcode reader device to read barcode to fetch data. So can i use the reader device with this?

Thanks.

Copy link

Can I use the Barcode Scanner for commercial reasons? And is there a way to make the scanning processes in the whole camera view and not only the marked section?

Copy link

I thinks QR code and Barcode format is different, I'm succesfully implement QR code scanner in web based with ease, but still struggling make barcode scanning works.

As far as I know, QR code using 2D matrix data to easily read by the reader/camera while barcode using font to generate barcode, different in read handling. CMIIW

Copy link

Some QR Code scan gives different-different results

Copy link

Hi,

i've problems with scanning colored qr. p.e. white qr on black ground.
Is there an option to generalize the color settings?

Kind regards,
Thomas

Copy link

If you want the result to come out as shown in the example, replace:

This:
html5QrcodeScanner.render(onScanSuccess);

For this:
html5QrcodeScanner.render(document.getElementById(onScanSuccess));

I hope it works for you.

Copy link

Hi,
I tried to scan a PDF_417 from an Id card and the camera doesn't focus, like its too little, is there a way to zoom it?
Regards
Karin

Copy link

juanski commented Nov 1, 2022

Hi Minhaz, Great write-up thanks for making this available. Scanning a standard 13-digit barcode works as expected on Android devices but just can't get it to scan on iOS devices. The camera comes on, no issue there, but it just won't capture/read the barcode.

Copy link

iPhone11 not working. not reading why?

Copy link

DakkeOG commented Feb 17, 2023

It works in the demo, but when I try to set it up in an HTML-file with a script section, it doesn't find camera options. The light of my camera goes on, though, after clicking 'ask camera permission' but the dropdown of camera's only has one option with an empty text and value (so ).

After calling Html5Qrcode.getCameras(), I get an empty id and empty label. How is it possible that it works in the demo, but not in my own html and .js file?

Copy link

this is working in the browser , but not showing up in the webview.. have anyone used this in the webview ???

Copy link

A good one. Great article Minhaz.

Copy link

Game changing solution, works perfectly. I'm stuck only with long C128 codes like this:

BJ0WX0E9500V1NAQ0186

try to code into Code-128 barcode - this barcode can't be recognized, however barcode scanning iOS/Android apps regognize it well((

Copy link

Hi, are there any plans to add DPM Data Matrix reading

Copy link

Hi, I am trying to scan Texas Driver's License, which is in PDF417 format but it is not scanning. Did any body successfully any PDF417 barcode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests