Skip to content

alexbabichev/QRReader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QRReader

library for reading QR codes from the webcam

Ready for usage in PWA, SPA (Angular, React, Vue, etc).

Compliled size: 5kB.

3rd party dependency: jsqr (https://github.com/cozmo/jsQR), size: 254Kb.

Methods

  isMediaStreamAPISupported(): boolean
  getVideoInputDevices(): Promise<MediaDeviceInfo[]>
  startCapture(video: HTMLElement, captureInterval?: number): Promise<string>
  stopCapture(): void
  stopAndSwitchCamera(): void

Usage Example

// import
import QRReader from 'QRReader';

// init
const qrCodeReader = new QRReader();
const videoElement = document.getElementById('video');

// start Capture
start() {
  qrCodeReader.startCapture(videoElement)
    .then(decodedData => {
      console.log(decodedData);
    })
    .catch(console.log);
}

// cancel Capture
onCancelClick() {
  qrCodeReader.stopCapture();
}

// switch input device
switchCamera() {
  qrCodeReader.stopAndSwitchCamera();
}

About

typescript library for reading QR codes from the webcam

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors