mirror of
https://github.com/frontendnetwork/vegancheck.me
synced 2024-11-10 06:24:13 +00:00
feat: Scanner
This commit is contained in:
parent
303a8e01ce
commit
b023eeecb2
2 changed files with 12 additions and 3 deletions
|
@ -21,14 +21,18 @@ class Scanner extends Component<ScannerProps, ScannerState> {
|
|||
const newFacingMode = facingMode === "environment" ? "user" : "environment";
|
||||
this.setState({ facingMode: newFacingMode });
|
||||
|
||||
const scaleFactor = 0.75;
|
||||
const width = window.innerWidth * scaleFactor;
|
||||
const height = window.innerHeight * scaleFactor;
|
||||
|
||||
Quagga.init(
|
||||
{
|
||||
inputStream: {
|
||||
type: "LiveStream",
|
||||
constraints: {
|
||||
width: window.innerWidth * window.devicePixelRatio,
|
||||
height: window.innerHeight * window.devicePixelRatio,
|
||||
aspectRatio: { ideal: window.innerHeight / window.innerWidth },
|
||||
width,
|
||||
height,
|
||||
aspectRatio: { ideal: height / width },
|
||||
facingMode: newFacingMode,
|
||||
},
|
||||
},
|
||||
|
|
5
types/quagga.d.ts
vendored
Normal file
5
types/quagga.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
declare module "quagga" {
|
||||
const Quagga: any;
|
||||
export default Quagga;
|
||||
}
|
||||
|
Loading…
Reference in a new issue