feat: Code Scanner API (#1912)
* feat: CodeScanner JS API * feat: iOS * Use guard * Format * feat: Android base * fix: Attach Surfaces * Use isBusy var * fix: Use separate Queue * feat: Finish iOS types * feat: Implement all other code types on Android * fix: Call JS event * fix: Pass codetypes on Android * fix: iOS use Preview coordinate system * docs: Add comments * chore: Format code * Update CameraView+AVCaptureSession.swift * docs: Add Code Scanner docs * docs: Update * feat: Use lazily downloaded model on Android * Revert changes in CameraPage * Format * fix: Fix empty QR codes * Update README.md
This commit is contained in:
62
package/src/CodeScanner.ts
Normal file
62
package/src/CodeScanner.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* The type of the code to scan.
|
||||
*/
|
||||
export type CodeType =
|
||||
| 'code-128'
|
||||
| 'code-39'
|
||||
| 'code-93'
|
||||
| 'codabar'
|
||||
| 'ean-13'
|
||||
| 'ean-8'
|
||||
| 'itf'
|
||||
| 'upc-e'
|
||||
| 'qr'
|
||||
| 'pdf-417'
|
||||
| 'aztec'
|
||||
| 'data-matrix'
|
||||
|
||||
/**
|
||||
* A scanned code.
|
||||
*/
|
||||
export interface Code {
|
||||
/**
|
||||
* The type of the code that was scanned.
|
||||
*/
|
||||
type: CodeType | 'unknown'
|
||||
/**
|
||||
* The string value, or null if it cannot be decoded.
|
||||
*/
|
||||
value?: string
|
||||
/**
|
||||
* The location of the code relative to the Camera Preview (in dp).
|
||||
*/
|
||||
frame?: {
|
||||
x: number
|
||||
y: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A scanner for detecting codes in a Camera Stream.
|
||||
*/
|
||||
export interface CodeScanner {
|
||||
/**
|
||||
* The types of codes to configure the code scanner for.
|
||||
*/
|
||||
codeTypes: CodeType[]
|
||||
/**
|
||||
* A callback to call whenever the scanned codes change.
|
||||
*/
|
||||
onCodeScanned: (codes: Code[]) => void
|
||||
/**
|
||||
* Crops the scanner's view area to the specific region of interest.
|
||||
*/
|
||||
regionOfInterest?: {
|
||||
x: number
|
||||
y: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user