GithubHelp home page GithubHelp logo

mebjas / html5-qrcode Goto Github PK

View Code? Open in Web Editor NEW
4.5K 81.0 905.0 22.27 MB

A cross platform HTML5 QR code reader. See end to end implementation at: https://scanapp.org

Home Page: https://qrcode.minhazav.dev

License: Apache License 2.0

JavaScript 0.60% Shell 0.29% TypeScript 98.82% Batchfile 0.29%
html5 qrcode camera barcode javascript scanning

html5-qrcode's Introduction

Html5-QRCode

Important - Looking for new owners for this project.

If interested, please reach out at [email protected].

Html5-QRCode

Important The project is in maintenance mode until further notice. The author shall not be able to make any bug fixes or improvements for the time-being. Pull requests also won't be merged for the timebeing. If you have a fork you can maintain - please share the details to [email protected]. I am happy to advertise them here! Ok to use the project as is. Example: scanapp.org.

Lightweight & cross platform QR Code and Bar code scanning library for the web

Use this lightweight library to easily / quickly integrate QR code, bar code, and other common code scanning capabilities to your web application.

Key highlights

Supports two kinds of APIs

  • Html5QrcodeScanner — End-to-end scanner with UI, integrate with less than ten lines of code.

  • Html5Qrcode — Powerful set of APIs you can use to build your UI without worrying about camera setup, handling permissions, reading codes, etc.

Support for scanning local files on the device is a new addition and helpful for the web browser which does not support inline web-camera access in smartphones. Note: This doesn't upload files to any server — everything is done locally.

CircleCI GitHub issues GitHub tag (latest by date) GitHub Codacy Badge Gitter

GitHub all releases npm

Demo at scanapp.org Demo at qrcode.minhazav.dev - Scanning different types of codes

We need your help!

image Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See list of sponsered feature requests here.

ko-fi

Documentation

The documentation for this project has been moved to scanapp.org/html5-qrcode-docs.

Supported platforms

We are working continuously on adding support for more and more platforms. If you find a platform or a browser where the library is not working, please feel free to file an issue. Check the demo link to test it out.

Legends

  • Means full support — inline webcam and file based
  • Means partial support — only file based, webcam in progress

PC / Mac

Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
Edge
Edge

Android

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Opera
Opera
Opera-Mini
Opera Mini
UC
UC

IOS

Safari
Safari
Chrome
Chrome
Firefox
Firefox
Edge
Edge
* *

* Supported for IOS versions >= 15.1

Before version 15.1, Webkit for IOS is used by Chrome, Firefox, and other browsers in IOS and they do not have webcam permissions yet. There is an ongoing issue on fixing the support for iOS - issue/14

Framework support

The library can be easily used with several other frameworks, I have been adding examples for a few of them and would continue to add more.

Html5 VueJs ElectronJs React Lit

Supported Code formats

Code scanning is dependent on Zxing-js library. We will be working on top of it to add support for more types of code scanning. If you feel a certain type of code would be helpful to have, please file a feature request.

Code Example
QR Code
AZTEC
CODE_39
CODE_93
CODE_128
ITF
EAN_13
EAN_8
PDF_417
UPC_A
UPC_E
DATA_MATRIX
MAXICODE*
RSS_14*
RSS_EXPANDED*

*Formats are not supported by our experimental integration with native BarcodeDetector API integration (Read more).

Description - View Demo

See an end to end scanner experience at scanapp.org.

This is a cross-platform JavaScript library to integrate QR code, bar codes & a few other types of code scanning capabilities to your applications running on HTML5 compatible browser.

Supports:

  • Querying camera on the device (with user permissions)
  • Rendering live camera feed, with easy to use user interface for scanning
  • Supports scanning a different kind of QR codes, bar codes and other formats
  • Supports selecting image files from the device for scanning codes

How to use

Find detailed guidelines on how to use this library on scanapp.org/html5-qrcode-docs.

Demo


Scan this image or visit blog.minhazav.dev/research/html5-qrcode.html

For more information

Check these articles on how to use this library:

Screenshots

screenshot
Figure: Screenshot from Google Chrome running on MacBook Pro

Documentation

Find the full API documentation at scanapp.org/html5-qrcode-docs/docs/apis.

Extra optional configuration in start() method

Configuration object that can be used to configure both the scanning behavior and the user interface (UI). Most of the fields have default properties that will be used unless a different value is provided. If you do not want to override anything, you can just pass in an empty object {}.

fps — Integer, Example = 10

A.K.A frame per second, the default value for this is 2, but it can be increased to get faster scanning. Increasing too high value could affect performance. Value >1000 will simply fail.

qrboxQrDimensions or QrDimensionFunction (Optional), Example = { width: 250, height: 250 }

Use this property to limit the region of the viewfinder you want to use for scanning. The rest of the viewfinder would be shaded. For example, by passing config { qrbox : { width: 250, height: 250 } }, the screen will look like:

This can be used to set a rectangular scanning area with config like:

let config = { qrbox : { width: 400, height: 150 } }

This config also accepts a function of type

/**
  * A function that takes in the width and height of the video stream 
* and returns QrDimensions.
* 
* Viewfinder refers to the video showing camera stream.
*/
type QrDimensionFunction =
    (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions;

This allows you to set dynamic QR box dimensions based on the video dimensions. See this blog article for example: Setting dynamic QR box size in Html5-qrcode - ScanApp blog

This might be desirable for bar code scanning.

If this value is not set, no shaded QR box will be rendered and the scanner will scan the entire area of video stream.

aspectRatio — Float, Example 1.777778 for 16:9 aspect ratio

Use this property to render the video feed in a certain aspect ratio. Passing a nonstandard aspect ratio like 100000:1 could lead to the video feed not even showing up. Ideal values can be:

Value Aspect Ratio Use Case
1.333334 4:3 Standard camera aspect ratio
1.777778 16:9 Full screen, cinematic
1.0 1:1 Square view

If you do not pass any value, the whole viewfinder would be used for scanning. Note: this value has to be smaller than the width and height of the QR code HTML element.

disableFlip — Boolean (Optional), default = false

By default, the scanner can scan for horizontally flipped QR Codes. This also enables scanning QR code using the front camera on mobile devices which are sometimes mirrored. This is false by default and I recommend changing this only if:

  • You are sure that the camera feed cannot be mirrored (Horizontally flipped)
  • You are facing performance issues with this enabled.

Here's an example of a normal and mirrored QR Code

Normal QR Code Mirrored QR Code

rememberLastUsedCamera — Boolean (Optional), default = true

If true the last camera used by the user and weather or not permission was granted would be remembered in the local storage. If the user has previously granted permissions — the request permission option in the UI will be skipped and the last selected camera would be launched automatically for scanning.

If true the library shall remember if the camera permissions were previously granted and what camera was last used. If the permissions is already granted for "camera", QR code scanning will automatically * start for previously used camera.

supportedScanTypes - Array<Html5QrcodeScanType> | []

This is only supported for Html5QrcodeScanner.

Default = [Html5QrcodeScanType.SCAN_TYPE_CAMERA, Html5QrcodeScanType.SCAN_TYPE_FILE]

This field can be used to:

  • Limit support to either of Camera or File based scan.
  • Change default scan type.

How to use:

function onScanSuccess(decodedText, decodedResult) {
  // handle the scanned code as you like, for example:
  console.log(`Code matched = ${decodedText}`, decodedResult);
}

let config = {
  fps: 10,
  qrbox: {width: 100, height: 100},
  rememberLastUsedCamera: true,
  // Only support camera scan type.
  supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA]
};

let html5QrcodeScanner = new Html5QrcodeScanner(
  "reader", config, /* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess);

For file based scan only choose:

supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_FILE]

For supporting both as it is today, you can ignore this field or set as:

supportedScanTypes: [
  Html5QrcodeScanType.SCAN_TYPE_CAMERA,
  Html5QrcodeScanType.SCAN_TYPE_FILE]

To set the file based scan as defult change the order:

supportedScanTypes: [
  Html5QrcodeScanType.SCAN_TYPE_FILE,
  Html5QrcodeScanType.SCAN_TYPE_CAMERA]

showTorchButtonIfSupported - boolean | undefined

This is only supported for Html5QrcodeScanner.

If true the rendered UI will have button to turn flash on or off based on device + browser support. The value is false by default.

Scanning only specific formats

By default, both camera stream and image files are scanned against all the supported code formats. Both Html5QrcodeScanner and Html5Qrcode classes can be configured to only support a subset of supported formats. Supported formats are defined in enum Html5QrcodeSupportedFormats.

enum Html5QrcodeSupportedFormats {
  QR_CODE = 0,
  AZTEC,
  CODABAR,
  CODE_39,
  CODE_93,
  CODE_128,
  DATA_MATRIX,
  MAXICODE,
  ITF,
  EAN_13,
  EAN_8,
  PDF_417,
  RSS_14,
  RSS_EXPANDED,
  UPC_A,
  UPC_E,
  UPC_EAN_EXTENSION,
}

I recommend using this only if you need to explicitly omit support for certain formats or want to reduce the number of scans done per second for performance reasons.

Scanning only QR code with Html5Qrcode

const html5QrCode = new Html5Qrcode(
  "reader", { formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ] });
const qrCodeSuccessCallback = (decodedText, decodedResult) => {
    /* handle success */
};
const config = { fps: 10, qrbox: { width: 250, height: 250 } };

// If you want to prefer front camera
html5QrCode.start({ facingMode: "user" }, config, qrCodeSuccessCallback);

Scanning only QR code and UPC codes with Html5QrcodeScanner

function onScanSuccess(decodedText, decodedResult) {
  // Handle the scanned code as you like, for example:
  console.log(`Code matched = ${decodedText}`, decodedResult);
}

const formatsToSupport = [
  Html5QrcodeSupportedFormats.QR_CODE,
  Html5QrcodeSupportedFormats.UPC_A,
  Html5QrcodeSupportedFormats.UPC_E,
  Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION,
];
const html5QrcodeScanner = new Html5QrcodeScanner(
  "reader",
  {
    fps: 10,
    qrbox: { width: 250, height: 250 },
    formatsToSupport: formatsToSupport
  },
  /* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess);

Experimental features

The library now supports some experimental features which are supported in the library but not recommended for production usage either due to limited testing done or limited compatibility for underlying APIs used. Read more about it here. Some experimental features include:

How to modify and build

  1. Code changes should only be made to /src only.

  2. Run npm install to install all dependencies.

  3. 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.

  4. Testing

    • Run npm test
    • Run the tests before sending a pull request, all tests should run.
    • Please add tests for new behaviors sent in PR.
  5. Send a pull request

    • Include code changes only to ./src. Do not change ./dist manually.
    • In the pull request add a comment like
    @all-contributors please add @mebjas for this new feature or tests
    
    • For calling out your contributions, the bot will update the contributions file.
    • Code will be built & published by the author in batches.

How to contribute

You can contribute to the project in several ways:

  • File issue ticket for any observed bug or compatibility issue with the project.
  • File feature request for missing features.
  • Take open bugs or feature request and work on it and send a Pull Request.
  • Write unit tests for existing codebase (which is not covered by tests today). Help wanted on this - read more.

Support 💖

This project would not be possible without all of our fantastic contributors and sponsors. If you'd like to support the maintenance and upkeep of this project you can donate via GitHub Sponsors.

Sponsor the project for priortising feature requests / bugs relevant to you. (Depends on scope of ask and bandwidth of the contributors).

webauthor@ ben-gy bujjivadu

Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See list of sponsered feature requests here.

Also, huge thanks to following organizations for non monitery sponsorships

Credits

The decoder used for the QR code reading is from Zxing-js https://github.com/zxing-js/library

html5-qrcode's People

Contributors

adamwolf avatar alfonsoml avatar allanbrault avatar alvin883 avatar amauric avatar bilal-elchami avatar chrros95 avatar daikichidaze avatar dampee avatar dependabot[bot] avatar dylancom avatar esin avatar goldyteam avatar gurubobnz avatar itsundefined avatar jac0xb avatar jackhe16 avatar jdtimmerman avatar jimver avatar jofftiquez avatar kusigit avatar kzha0 avatar mebjas avatar mohsinaav avatar mrgussio avatar pholawat-tle avatar rlueder avatar rtiscool avatar seyfer avatar zolfariot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

html5-qrcode's Issues

Recognized scan-region for small viewports

Bug
There seems to be a problem with the recognized scan-region for small viewports. I printed a qr-code in the size of a hand and I'm trying it to scan with an iPhone 7 using a qr-box with 350x350px (and boxsize in code is not set, thus it should use full dimension).

You have to hold your phone about 0,5m far away only for having a chance to get a match. And then it only succeeds in round about one out of ten trials. It works great with macbook-cam, when using a qr-box with more than 600+ px. But reducing step by step the size also works bad on desktop browser.

Describe the browser:

  • OS: iOS on iPhone 7
  • Browser: Safari
  • Version: latest

Screenshots
Fails on desktop too:

202004120_200432-CapturFiles

Additional context
Box: 350x350
BoxSize in JS: null

I can provide a playground if required.

Same QR code scan gives different results

Describe the bug
When scanning, same QR code different results. Though it's random but very frequent.

Sample QR code:
sample qr

Scan results:
Screenshot_20200616-092601

Expected result: {"bp_id":"eb1faf1fa48e1801","pt_id":"d78f8bbd036be151"}

As you can see following results are not correct:
2nd result: pv_id instead of pt_id
4th result: "bp_id":2eb1... instead of "bp_id":"eb1
6th result: "bp_id":"...1841" instead of "bp_id":"...1801"
8th result: "br_id" instead of "bp_id"

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://blog.minhazav.dev/research/html5-qrcode.html
  2. Scan the given QR code.

Expected behavior
Scan result should always show: {"bp_id":"eb1faf1fa48e1801","pt_id":"d78f8bbd036be151"}

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: 83.0.4103.97

Smartphone (please complete the following information):

  • Device: Nexus 6P
  • OS: android 8.1.0
  • Browser: Chrome
  • Version: 83.0.4103.96

[Feature Request] facingMode constraint is essential for this library to work

Very nice and clean module but... is useless without facingMode constraint, device label can be in any language making the camera choice impossible

Example:

{id: "AFB981283186FBA62F2947AA63940A4482BF80C3", label: "Πίσω κάμερα"}

Alternative, selecting between 4 options (devices), where only one option is essential its not the best user experience

Slow video rendering on web camera with high resolution and framerate

On my Logitech web camera with following capabilities

aspectRatio: {max: 2304, min: 0.0006510416666666666}
deviceId: "82962ef9fc3321fd02f74391ba1875f05e48f38023e5ada576d59ae269a4ea5d"
facingMode: []
frameRate: {max: 60.000240325927734, min: 0}
groupId: "32b4e6de674cf9466b719cea29e4e9aff166cf5b3ffbcca97fed6575c73f99f2"
height: {max: 1536, min: 1}
resizeMode: (2) ["none", "crop-and-scale"]
width: {max: 2304, min: 1}

The video rendering is slow.

Camera does not stop scanning

Describe the bug
A call to stopScanning() does not stop scanning im some cases.
Maybe it's a problem, that I'll do this in a timeout-callback.

Reason: I'am doing a pattern-matching on scanned result ... this happens very fast in success-case. For providing a better UX, I add a small timeout for giving interaction-feedback to current user ... before I'll do other stuff in my final implementation.

To Reproduce
Modify Success-Callback this way:

    if(qrCodeMessage == matchingPattern) {
      resultBox.innerHTML = qrCodeMessage; // my test-div
      setTimeout(function() {
        stopScanning();
      }, timeoutAfterScan);
    }

Expected behavior
Should close the stream in any case when invoking stopScanning()

Screenshots
n.a.

Smartphone:

  • Device: [e.g. iPhone*]
  • OS: [iOS*]
  • Browser [safari*]
  • Version [*]

Additional context
n.a.

Camera zoomed out and to one corner

I am having a problem in which the canvas element does not match the video element. The video centers in and looks right. However, if I make the canvas element visible it has a very different view which is looks like the high left corner of the camera zoomed out. This seems to be the case across devices and browsers, but is worse on smaller devices. Any ideas what could cause these two elements to be out of sync and how I might re-align them?

Thank you. Btw, when the QR is within the canvas element it works great!

Video Error , error = Error getting userMedia, error = NotReadableError:Could not start video source on low end Android devices

Describe the bug
When you press request permission button.
It will run navigator.mediaDevices.getUserMedia({ audio: false, video: true }).then(_ => from static getCameras() method

  • which causes the browser to already start accessing the video input. Causing NotReadableError when pressing start scanning after selecting the REAR CAMERA (Front camera has no issues)
  • But do note that ONLY slow phones will be affected. Any phones that are slow enough can reproduce this issue in the demo website.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the demo website https://blog.minhazav.dev/research/html5-qrcode.html
  2. Click on Request Permission and scroll down your notification bar. You will see chrome is already accessing your video input. If your phone is slow enough. Quickly go to point 3
  3. Select REAR camera and Press Start scanning while chrome still accessing your video input
  4. See error Video Error , error = Error getting userMedia, error = NotReadableError:Could not start video source

To avoid the NonReadableError

  1. You have to wait chrome browser to stop accessing the video input after pressing the (request permission button) for around 5 seconds or even more for the notification of chrome accessing your video input is gone at the notification bar! the range of time depends the phone's performance
  2. Then you press start scanning after selecting the REAR CAMERA

Expected behavior
See error Video Error , error = Error getting userMedia, error = NotReadableError:Could not start video source

The Fix
Just comment the code shown in the screenshot.
//navigator.mediaDevices.getUserMedia({ audio: false, video: true })
// .then(_ => {
**content
//.catch(err => {
// reject(${err.name} : ${err.message});
//})
the fix

Screenshots
Request Permission
The error message

Desktop (please complete the following information):
Desktop basically have no issue because PCs are too fast

Smartphone (please complete the following information):

  • Device: Huawei Nova 3i, Huawei Honor 10
  • OS: EMUI 9.1 for both phones
  • Browser [Chrome- 81.0.4044.117 (latest version)]

Additional context
I'm sorry if I raised a wrong issue.

Get coordinates and size of QR Code

I would like to be able to get the location (coordinates) and size (width and height) of the QR-code inside the viewport/camera viewfinder?
Preferrable continuously (i.e.: When user moves camera, QR Code will be «moved» inside the viewfinder, and I want to be able to catch the position/size at all times)

Violation setTimeout in html5qrcode.js

When scanning with your library I get continuous console messages saying:
[Violation] 'setTimeout' handler took 73ms
This error is reported to occur on line 211 og html5qrcode.js.
NOTE: The scanning appears to work, though.

Desktop (please complete the following information):

  • OS: macOS latest
  • Browser: Chrome
  • Version: Latest

Device id (camera id) gets changed in android app webview

Describe the bug
I'm developing an android app, which has a webview in it. When loading the qr scanning demo page (https://blog.minhazav.dev/research/html5-qrcode.html) or a page that implemented the html5-qrcode library, device id (camera id) gets changed every time I reload the webpage, where as in mobile browser or desktop browser the device id remains same. In my app I like to save user's preferred camera which requires an unique id, but as the id gets changed when the webpage is reloaded it's not possible.

sample:
1st load:
id: "4c2c562185edeff69ceb28984aec24160b359fc3567422065818a41e4070f60c"
label: ""
2nd load:
id: "66a9bae5d6fdf95016203d260be74cff7b0e96deb14c91d768851353d4d3461b"
label: ""
3rd load:
id: "52dd763ec80c3e48726ab7617e2e37444278d90abd768414468a16f8e7728c0e"
label: ""

To Reproduce
Steps to reproduce the behavior:

  1. Load https://blog.minhazav.dev/research/html5-qrcode.html in android webview
  2. Check loaded devices array from remote debugging of chrome developer console by running following code in console: Html5Qrcode.getCameras().then(devices => {console.log(devices);});

Expected behavior
Device id should be unique for same device.

Smartphone (please complete the following information):

  • Device: Nexus 6P
  • OS: android 8.1.0

Demo QR Code scanner unable to read code

Describe the bug
I tried the demo but the scanner is unable to decode my QR code. Everything else works up until that point. Accept my sincere apology if I'm doing something wrong. Thanks for your great work.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://blog.minhazav.dev/research/html5-qrcode.html
  2. Click on Request Permission
  3. Click on "start scanning"
  4. Position your qr code in front of camera and adjust until qr code falls within the target box

Expected behavior
Scanner should return decoded text.

  • Browser: Chrome Version 81.0.4044.129

Field-Test for compatibility (Mobile-Only)

Maybe we can keep this ticket running for continuous feedback.

Keys:
Cams: Num of cams
QR: Does QR-Scanning work?
File: Does File-Scanning work?
AS: AutoSelect back-camera (pattern-matching on label)
SC: Stream-Close after scan (currently a problem; TBR)

... AS is not relevant for your code-base, but I'll just copy and paste my test-table ... just ignore it

Error-Cases:

  1. Just really nothings happens, even no camera-access-dialog
  2. Unable to close the stream
  3. VideoError, error = Error getting userMedia; error = NotReadableError: Could not start video source

Symbols:
✅ ... everything is fine
🔴 ... does not work as excpected
⚪ ... not yet checked
❓ ... not yet clear or missing feedback

vue the import prompt is not defined

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Device label (human-readable name for the camera device) is empty string in android app webview

Describe the bug
I'm developing an android app, which has a webview in it. When loading the qr scanning demo page (https://blog.minhazav.dev/research/html5-qrcode.html) or a page that implemented the html5-qrcode library, device label (human-readable name for the camera device) is empty string.

sample:
id: "4c2c562185edeff69ceb28984aec24160b359fc3567422065818a41e4070f60c"
label: ""

To Reproduce
Steps to reproduce the behavior:

  1. Load https://blog.minhazav.dev/research/html5-qrcode.html in android webview
  2. Click "Select Camera" drop down list.

Expected behavior
Device names (camera) should be shown in drop down list.

Smartphone

  • Device: Nexus 6P
  • OS: android 8.1.0

Add support for automated transpiling and minification

Current workflow before sending a change is like this:

  1. Make changes to html5-qrcode.js
  2. Transpile it to proper js code using babeljs.io --> transpiled/html5-qrcode.js
  3. Minify jsqrcode-combined.js and this transpiled code and merge them to minified/html5-qrcode.min.js

It'd be good to automate these steps.

Add tests and CI

Add test for the js code and connect to some CI like travis CI

Html5QrcodeScanner needs css fix

The demo page running Html5QrcodeScanner has more modern UI because of existing dependencies in the webpage.

OTOH, without any existing css the UI is much primitive.

This gives an advantage that the UI of the scanner can implicitly match the theme of the website it's attached to.

Considering pros and cons - make minimal fixes to the style or alternatively make this configurable.

[Feature Request] Support ondevice rotation in Mobile devices

The library doesn't adapt to orientation changes or size changes of the browser tab. Which distorts the whole UI in case of rotation

For example this is the visible UI in case auto rotate is on on an Android device and the device is rotated after the UI has rendered

image

Similar observed for IOS device
image

Error locator degree does not match number of roots

I'm getting QR code parse error, error = Error locator degree does not match number of roots error when parsing

download

as a file.

zbar however works fine:

> zbarimg ~/Downloads/download.png
QR-Code:http://localhost:4000/sensors/f1eb00a6-7e84-426a-9fd5-01ab709349b3
scanned 1 barcode symbols from 1 images in 0.03 seconds

Does this still work?

This library would be incredibly neat if it worked for it is far tinier than many other implementations. However, when I use this in my browser I see no image from the camera and it yields the following error in the console:

Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.
    at successCallback (html5-qrcode.js:87)

Edit: i'm using chrome on a laptop:

Version 71.0.3578.98 (Official Build) (64-bit)

Compatibility - [IOS] [Safari] - The visible QR box region and canvas are not aligned

Describe the bug
The region visible under the qrbox (region other than the shaded region) is not exactly aligned with the what is printed on canvas leading to bad UX during scanning.

Describe the browser:

  • OS: IOS
  • Browser Safari
  • Version Latest

Additional context

  • To reproduce make the canvas visible and see the output.
  • Validate this for other android browsers as well.

[Feature Request] Fully contained QR Code scanner

Implement a fully container QR Code scanner which require minimal implementation from users

It should support

  • Scanning using webcam
    • Camera Switch
    • Permission request
  • File scanning

User should just setup the qrcode scanner with something like:

const htmlQrcode = HtmlQrcode.createWithUI("qr");
htmlQrcode.render();

Cannot read a specific QR code

Describe the bug
Cannot read a specific QR code, although it is readable in other qr code scanning library/app.

QR code:

qr_config

Data of the QR code: "action":"config"

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://blog.minhazav.dev/research/html5-qrcode.html
  2. Scan the given QR code.

Expected behavior
Scan result should show: "action":"config"

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: 83.0.4103.97

Smartphone (please complete the following information):

  • Device: Nexus 6P
  • OS: android 8.1.0
  • Browser: Chrome
  • Version: 83.0.4103.96

Error : QR code parse error, error = couldn't find enough finder patterns

Dear Sir/Madam,

I test html5qrcode with below codes. And, when I scanned QR code, below error message is responded in "errorMessage". May I know how to fix it ?

errorMessage=QR code parse error, error = couldn't find enough finder patterns

<!DOCTYPE html>
<html>
<head>

<script src="html5-qrcode.min.js"></script>

</head>

<body onload="checkcameras()">

<div id="reader"></div>
<p id="demo"></p>


<script>

function onScanSuccess(qrMessage) {
	console.log("QR matched = ${qrMessage}");
}

function onScanFailure(error) {
	console.warn("QR error = ${error}");
}


function checkcameras() { 

Html5Qrcode.getCameras().then(devices => {
  
  if (devices && devices.length) {
	var cameraId = devices[1].id;
	const html5QrCode = new Html5Qrcode("reader", true);

	html5QrCode.start(
	  cameraId,     
	  {
		fps: 10,    
		qrbox: 500  
					
	  },
	  qrCodeMessage => {
		document.getElementById("demo").innerHTML = qrCodeMessage;	
	  },
	  errorMessage => {
		document.getElementById("demo").innerHTML = Date.now() + "--" + errorMessage;			
	  })
	.catch(err => {
	
	});
		
  }
}).catch(err => {

});
}

</script> 

</body>

</html>

Martin.

Assigning 'qrcode' externally causes the library to fail decoding of QR codes.

Describe the bug
The library internally utilizes 3rd party 'qrcode' module for QR-code decoding tasks. However there is not sufficient abstraction such that assigning 'qrcode' to something else externally to the library will cause the library to fail and flag errors such as qrcode.decode() failures.

To Reproduce
Steps to reproduce the behavior:

  1. Assign qrcode to something else after Html5Qrcode has been initialized:
const html5QrCode = new Html5Qrcode(/* element id */ "reader");
var qrcode = '';
  1. Start html5QrCode as usual, but parse the error.

  2. Observed error:

QR code parse error, error = TypeError: qrcode.decode is not a function

Expected behavior
It would be ideal to have sufficient abstraction such that assigning 'qrcode' externally to something else will not cause the library to break. Either that or mention it as a reserved word in the README.

Screenshots
N/A

Desktop (please complete the following information):

  • Any

Smartphone (please complete the following information):

  • Any

Additional context
N/A

Thanks!
Andrew

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.