Last active
July 20, 2022 23:51
-
-
Save eddiemoore/04678592bc7894079857790c70cf823c to your computer and use it in GitHub Desktop.
BarcodeDetector TypeScript types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Spec: https://wicg.github.io/shape-detection-api/#barcode-detection-api | |
*/ | |
interface BarcodeDetector { | |
detect(image: ImageBitmapSource): Promise<DetectedBarcode[]>; | |
} | |
type BarcodeFormat = | |
| "aztec" | |
| "code_128" | |
| "code_39" | |
| "code_93" | |
| "codabar" | |
| "data_matrix" | |
| "ean_13" | |
| "ean_8" | |
| "itf" | |
| "pdf417" | |
| "qr_code" | |
| "unknown" | |
| "upc_a" | |
| "upc_e"; | |
interface BarcodeDetectorOptions { | |
formats: BarcodeFormat[]; | |
} | |
interface Point2D { | |
x: number; | |
y: number; | |
} | |
interface DetectedBarcode { | |
readonly boundingBox: DOMRectReadOnly; | |
rawValue: string; | |
format: BarcodeFormat; | |
cornerPoints: Point2D[]; | |
} | |
interface BarcodeDetectorConstructor { | |
/** | |
* A reference to the prototype. | |
*/ | |
readonly prototype: BarcodeDetector; | |
/** | |
* Creates a new BarcodeDetector. | |
*/ | |
new (barcodeDetectorOptions?: BarcodeDetectorOptions): BarcodeDetector; | |
static getSupportedFormats(): Promise<BarcodeFormat[]>; | |
} | |
declare var BarcodeDetector: BarcodeDetectorConstructor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment