100 Commits
Author SHA1 Message Date
Daniel abcfe1bce2 v1.4.2 2022-11-22 21:05:48 -06:00
Daniel 987bbb06c2 Disable native BarcodeDetector on M1/M2 Macs with Ventura
On Macs with an M1/M2 processor and macOS Ventura (macOS version 13), the BarcodeDetector
is broken in Chromium based browsers, regardless of the version. For that constellation,
the BarcodeDetector does not error but does not detect QR codes. Macs without an M1/M2 or
before Ventura are fine. See https://bugs.chromium.org/p/chromium/issues/detail?id=1382442.

Fixes #209
2022-11-22 21:01:12 -06:00
Daniel 34bccc6b27 Readme: add additional notes of using new api vs old 2022-06-02 00:09:38 +02:00
Daniel 1cd3b15285 v1.4.1 2022-02-22 23:28:17 +01:00
Daniel 2714cb9944 Identify scan requests to worker by unique id's
This avoids that parallel scans on the same worker instance ALL interpret
the first incoming scan result as their result. Instead, now each scan
request to the worker waits for their individual response.

Fixes #149
2022-02-22 23:27:02 +01:00
Daniel 9373237718 Always create new worker instead of reusing a singleton worker
Create a new worker instance on each call to createQrEngine instead of
using a singleton worker instance. Sharing a singleton instance resulted
in problems when destroying the worker, for example in a call to
QrScanner.scanImage, while it was still needed in a scanner instance or
further calls to scanImage.
2022-02-22 18:17:13 +01:00
Daniel 3a2719213b Improve documentation for .destroy()
Make clear that destroyed instances can not be started again.

Closes #144
2022-02-21 14:36:54 +01:00
Daniel 9a70dd984c Fix type generation for namespaced types
Fixes #147
2022-02-21 14:36:54 +01:00
Daniel 78e65c6b42 Build legacy build as umd instead of esm
Building as es module doesn't make too much sense as browser support for
es modules is lower as for es6 generally, and anyone who would import the
legacy build via es import, could already pretty much use the regular build.

Also improves on documentation for legacy build.

Closes #143
2022-02-08 23:39:17 +01:00
Daniel 8bb46c3cbc v1.4.0 2022-02-04 12:18:13 +01:00
Daniel 2991d0a411 Inline worker script in legacy build
Older browsers that arleady supported es6 did not support dynamic imports.
Also change worker output type to esm as the build is slightly smaller.
2022-02-03 16:48:11 +01:00
Daniel d4bbd3b02d Restructure rollup.config.js
Now avoids duplication of common options between regular and legacy build.
Also adding more comments.
2022-02-02 22:32:04 +01:00
Daniel 60a2b3b2ce Import worker as dynamic import
Doed now not import the worker as a separate worker script via the Worker
constructor which required copying over the worker script and specifying
QrScanner.WORKER_PATH. Instead, the dynamic import will now be handled
automatically by bundlers like Rollup or Webpack.
2022-02-02 17:42:30 +01:00
Daniel 54b40bf917 Nicer default highlight styles 2022-01-28 19:17:22 +01:00
Daniel 70335ba5c2 Better handling of internal issues of native BarcodeDetector
Fixes #98
2022-01-28 18:24:20 +01:00
Daniel 3ce4f1bf6b Limit scan rate to camera's frame rate 2022-01-28 18:24:20 +01:00
Daniel 8ee8d7a45a Support throttling the scans per second
Closes #93
2022-01-28 18:24:20 +01:00
Daniel 158fbf585b Support providing an external overlay element 2022-01-28 18:24:20 +01:00
Daniel 0d48a807f5 Support highlighting the outline of detected codes 2022-01-28 18:24:13 +01:00
Daniel 16ad9b9b82 Smarter positioning of scan region highlight
Now does not make any assumptions on the parent element anymore and can
handle object-fit or object-position being set on the video.
2022-01-26 18:10:12 +01:00
Daniel 6cffe506d6 Demo: add examples of custom scan region highlight styling 2022-01-26 16:43:32 +01:00
Daniel dea704924f Support highlighting the scan region
Closes #86
2022-01-26 16:43:25 +01:00
Daniel 57b2a52734 Provide more detailed scan results, for now adding qr location
Closes #66
Closes #109
2022-01-25 11:59:08 +01:00
Daniel 954d3e2930 Switch constructor and scanImage to using options objects 2022-01-25 10:21:26 +01:00
Daniel b769540c3b Improve handling of pending actions if scanner was paused or destroyed
- Avoid starting camera stream if scanner was paused in the meantime
- Be lenient on fails to .start() if the scanner was paused in the meantime
- Disallow starting the stream or flash if the scanner was destroyed
- Await video.play calls

Fixes #90
Fixes #139
2022-01-25 10:21:26 +01:00
Daniel d704d3ab37 Don't open a second stream if we already have permission for device listing
This is an optimization but also a fix for iOS Safari which stops an already ongoing
stream when a second stream is opened, see https://bugs.webkit.org/show_bug.cgi?id=179363.

Fixes #125
2022-01-25 10:21:26 +01:00
Daniel a3e87bcf1e Remove limitation to MediaStreams as video srcObject 2022-01-25 10:21:26 +01:00
Daniel 2ba049f759 Switch to yarn 2022-01-25 10:21:26 +01:00
Daniel ce3189aeb0 Automatically generate type declarations 2022-01-25 10:21:26 +01:00
Daniel bcd5b19f82 Convert to typescript 2022-01-25 10:20:37 +01:00
Daniel ffdb944b62 Update closure compiler
Now generates slightly smaller builds
2022-01-20 09:10:15 +01:00
Daniel 8041e59ad7 Add legacy ECMAScript 2015 (ES6) build 2022-01-19 20:57:10 +01:00
Daniel 8bf0dc47aa Convert to ES2017 with async/await
Also saves 4.3% in size for qr-scanner.min.js
2022-01-19 17:58:59 +01:00
Daniel 72049e55bd v1.3.0 2021-08-17 12:37:09 +02:00
Daniel a1493c127d Check whether BarcodeDetector.getSupportedFormats exists
Some browsers (iOS specific?) had issues, see issue #115.
2021-08-17 12:10:51 +02:00
Daniel f232f32211 Support hasFlash even if no stream is currently running
But still doing it after scanner.start() is recommended, to avoid creating
a temporary stream.
2021-08-17 12:02:35 +02:00
Daniel 2877944bce Refactor hasFlash to potentially support Firefox and Safari in the future 2021-08-17 08:53:28 +02:00
Daniel fe31236d51 Fix turning flash off
applyConstraints with torch: false does not work to turn the
flashlight off, as a stream's torch stays continuously on, see
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#torch.
Therefore, we have to stop the stream to turn the flashlight off.
2021-08-16 21:20:32 +02:00
Daniel e2edfe1e88 Restart the flash if it was previously on
Also now support flagging the flash as on while the stream is
paused.
2021-08-16 21:14:29 +02:00
Daniel 5f13ff064e Merge PR#112 (lafriks-fork:feat/camera_list) with fixes 2021-08-16 14:08:30 +02:00
Daniel 4cfaf31fe5 Demo: update flash availability when switching camera 2021-08-16 14:03:56 +02:00
Daniel 28c43cdbe3 Simplify and improve setCamera
- Use .pause instead of copying the code
- Remove the unnecessary 300ms delay
- Avoid overwriting _offTimeout if another pause call happened shortly
  before.
- Don't start the stream if is was paused.
2021-08-16 13:40:56 +02:00
Daniel 6a6c593c2d Merge deviceId and preferredFacingMode into preferredCamera
- Merge deviceId and preferredFacingMode options into a single
  option preferredCamera. Also previously, the deviceId took
  precedence over the preferredFacingMode.
- .setCamera now also allows setting a preferred facingMode
  instead of a deviceId.

Additinal fixes to PR#112:

- Correctly fallback to not applying any constraints in .start if
  the preferredCamera (previously deviceId and preferredFacingMode)
  is not available. Previously, if neither for the deviceId nor
  the preferredFacingMode contraint a camera was found, no attempt
  without a constraint was attempted.
- A add missing documentation for deviceId support in the constructor
  to the Readme and generally adapt Readme for merged preferredCamera
  option.
- Fix missing type for deviceId (now merged into preferredCamera) in
  the constructor type definitions and generally adapt the types for
  merged preferredCamera option.
2021-08-14 14:13:33 +02:00
Daniel 1e9f6c6598 Refactor listCameras and improve readme wording
- rename the method from getCameraList to listCameras
- make requesting labels (and the required camera permission) optional
- refactor hasCamera using listCameras

Additinal fixes to PR#112:

- add fallback labels for when no exact labels were requested
- remove unnecessary outer Promise
- make sure the created stream is always destroyed in a finally
2021-08-13 20:49:59 +02:00
Daniel 450de34ae3 Update our jsQR fork
Especially with the following changes:
- Attempt to fix Safari RangeError exceptions
- Support "structured append" qr codes
- Binarizer: adapt blackBias for slightly higher detection rate
2021-08-10 21:00:35 +02:00
Daniel d7a09be088 Avoid that Safari stops the video stream on hidden videos 2021-08-09 11:22:27 +02:00
Daniel e8d107a171 Performance improvements
- round scan region to whole pixel positions to avoid blurry
  drawing at sub-pixel positions
- avoid clearing the canvas by resetting the canvas width or
  height when they actually didn't change.
2021-07-29 19:37:15 +02:00
Daniel 5836ac719b Rename fixedCanvasSize to disallowCanvasResizing 2021-07-29 17:26:29 +02:00
Daniel e8a77dea3f Add option for providing a custom web cam scanning region 2020-07-12 18:57:29 +02:00
Daniel 89201b62e8 v1.2.0 2020-07-12 14:21:57 +02:00
Daniel 99111ae23a When the native BarcodeDetector crashed, create a new one
The BarcodeDetector sometimes crashes after some time. If that happens,
create a new one.
2020-07-12 13:01:05 +02:00
Daniel 423101663b Use native BarcodeDetector when supported 2020-07-12 12:30:38 +02:00
Daniel 87336c313b Update source rect when video ready
b3713f2 switched to starting to play immediately, without waiting for
a canplay event. The side effect of this is, that the play event (on
which the source rect is measured) is triggered before the video
is ready and the video dimensions known. To circumvent this, this
commit adds an additional source rect update on loadedmetadata.
2020-07-12 00:00:56 +02:00
Daniel ecc04840dd Increase the timeout
Sometimes when the scanner was processing a frame for a long time, the
timeout apparently could be triggered when it shouldn't.
2020-07-11 10:05:49 +02:00
Daniel f1ca69bb1e Readme: add documentation for some so far undocumented features
- support for image urls and data urls
- support for stopping web cam scanning via stop()
- support for hasCamera() check
- documentation for optional scanImage() parameters
- update file sizes
- list web cam scanning out-of-the-box as a feature of this lib
2020-07-11 10:04:57 +02:00
Daniel 509232f8d1 Support blobs as image source 2020-07-10 20:42:48 +02:00
Daniel 9ec0d32131 Add an umd build 2020-07-10 00:10:45 +02:00
Daniel c0f922bdda Update jsQR scanner lib
New version of our jsQR-es6 fork has been updated to newest master
of cozmo/jsQR and merged in additional pull requests which are still
open in cozmo/jsQR. Also now makes the 'onlyInvert' inversion mode
usable.
2020-07-09 21:58:13 +02:00
Daniel efaec08208 Update all dependencies and rebuild 2020-07-09 17:20:10 +02:00
Daniel 4206f44c22 Make sure hasCamera() always returns a Promise 2020-07-09 16:36:44 +02:00
Daniel a3fcd4cf69 Fixes and improvements for flashlight support
- Add instructions to readme
- Update _flashOn after the flash was actually turned on or off
- Throw an error when trying to set the flash if not supported
- Make toggleFlash, turnFlashOn, turnFlashOff return a promise
- Throw an error when trying to detect flash support before the
  video stream is available.
2020-07-09 14:31:41 +02:00
Daniel 947fb7ebcf Improvements and fixes for continous scanning error handling
- Make change backwards compatible with previous consructor signature
- Fix demo to interpret errors as proper results
- Update types
- Do not report errors when the scanner is inactive
- Update readme
2020-07-07 23:45:49 +02:00
DanielandGustavo Honorato ee9e8f6fe6 Readme: improve webpack usage instructions
Improve the instructions for file-loader and add instructions for
raw-loader (see PR #60).

Co-authored-by: Gustavo Honorato <gustavohonorato@gmail.com>
2020-07-07 14:36:50 +02:00
Daniel 7776d8bca0 demo: add start and stop button 2020-07-06 23:31:20 +02:00
Daniel 1daf447a73 On pause stop all tracks if there are multiple
Should typically not be necessary, just to be safe.
2020-07-06 23:31:18 +02:00
DanielandAlessandro Gatti 177a252488 Set playsInline, muted and disablePictureInPicture by default
Set these properties by default to disable picture in picture mode and to
enable inline playback on iPhones.

Co-authored-by: Alessandro Gatti <ale.gatti96@gmail.com>
2020-07-06 23:30:36 +02:00
Danielandshrpne b3713f2b38 Remove canplay logic
The manual call of play() just after setting the video stream introduced in
the previous commit seems to suffice without the need to wait for the
canplay event.

Co-authored-by: shrpne <shrpne@gmail.com>
2020-07-05 13:45:29 +02:00
Daniel ecd8a3425f rebuild with much smaller file size 2019-02-17 11:25:13 -06:00
Daniel 18c3e4dff8 clean up temporarly created worker in single image scan 2019-02-16 22:40:10 -06:00
Daniel d5a8fe70e8 switch to jsQR library 2019-02-16 22:20:13 -06:00
Daniel baeb1986f5 make ready for npm package publication 2019-02-05 14:18:36 -06:00
Daniel 56b8dafcd4 update Readme 2019-02-05 12:04:14 -06:00
Daniel 0cc9ee2841 change default QrScanner.WORKER_PATH; fix WORKER_PATH in demo 2019-02-05 09:45:48 -06:00
Daniel 2144b169d1 add method for checking whether device has a camera 2019-02-05 09:32:48 -06:00
Daniel b3371bd2f1 move public methods to the top of QrScanner class 2019-02-05 08:28:51 -06:00
Daniel 8a1aff3353 add typescript types 2019-02-04 22:16:42 -06:00
Daniel 2637e698fd fix entry point in package.json 2019-01-19 17:10:37 +01:00
Daniel 788a65bb24 add destroy method 2019-01-19 17:10:27 +01:00
Daniel 27e40bf1ce pause video if tab in background; start playback also on video that does not provide autoplay 2019-01-19 17:02:02 +01:00
Daniel f5771a8279 add support for color inverted inverted qr codes; improve readme; more specific error messages; warn on http connection 2018-12-15 09:32:49 -06:00
danimoh c3a69b66a7 reset the _active flag to false if starting the camera fails 2018-01-23 22:15:34 -06:00
danimoh 5f6026512c return a resolving promise, if camera is already running 2018-01-23 20:09:30 -06:00
danimoh 9f13213c12 return a promise that indicates whether the camera could be started 2018-01-23 20:06:31 -06:00
danimoh 5fbba8f0b8 fix qr worker path 2018-01-22 14:58:13 -06:00
danimoh 26e90bf125 refactor into module 2018-01-21 20:36:42 -06:00
danimoh 67c351ff21 mirror the video for user facing cameras 2018-01-18 17:51:20 -06:00
danimoh 45e8429fd6 avoid double activation 2018-01-13 19:58:43 +01:00
danimoh b49910729d option to scan on the whole image if scanning within sourceRect failed 2018-01-12 15:35:37 +01:00
danimoh 5b7f4685ac add source maps 2018-01-07 15:32:15 +01:00
danimoh 0b69fc91ce update readme 2018-01-07 14:28:25 +01:00
danimoh fc62e3a404 - Fix build proccess
- Fix renaming of QrScannerLib To QrScanner
- Merge branch 'master' of github.com:nimiq-ux/qr-scanner
2018-01-07 13:39:56 +01:00
danimoh fc96eb3cf1 create the QR scanner canvas internally 2018-01-07 12:53:06 +01:00
danimoh ea71627d5d fix support detection for ImageBitmap and OffscreenCanvas 2018-01-06 21:10:48 +01:00
danimoh 9da68847c1 refactor scanner lib to also use scanImage for webcam frames 2018-01-06 20:53:40 +01:00
danimoh 24f71683ab Merge branch 'master' of github.com:nimiq-ux/qr-scanner 2018-01-06 17:46:54 +01:00
danimoh cc8cb4b670 Scan QR code in image files 2018-01-06 17:44:05 +01:00
danimohandGitHub 6a39bd348c Merge pull request #1 from nimiq/add-license-1
add license
2017-12-05 20:52:45 -06:00
danimohandGitHub d35294d445 add license 2017-12-05 20:51:44 -06:00
danimoh fc22116dd3 possibility to change grayscale weights via API 2017-12-05 20:40:38 -06:00
danimoh 4a536e58d3 Merge branch 'master' of github.com:nimiq-ux/qr-scanner 2017-12-05 20:34:17 -06:00