feat(firebase-vision): add image labelling (#3569)
* feat(firebase-vision): add image labelling * style(firebase-vision): update asterisks to pass lint * fix(firebase-vision): fix interfaces
This commit is contained in:
parent
fd0cddc9d0
commit
af114f48e4
@ -1,6 +1,40 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
||||||
|
|
||||||
|
export interface Text {
|
||||||
|
text: string;
|
||||||
|
blocks: TextLine[];
|
||||||
|
imageHeight: number;
|
||||||
|
imageWidth: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TextLine extends TextBlock {
|
||||||
|
lines: TextElement[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TextElement extends TextBlock {
|
||||||
|
elements: TextBlock[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TextBlock {
|
||||||
|
text: string;
|
||||||
|
cornerPoints: TextPoint[]
|
||||||
|
frame: TextFrame
|
||||||
|
recognizedLanguages: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TextPoint {
|
||||||
|
x: number,
|
||||||
|
y: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TextFrame {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
width: number,
|
||||||
|
height: number
|
||||||
|
}
|
||||||
|
|
||||||
export enum BarcodeFormat {
|
export enum BarcodeFormat {
|
||||||
UNKNOWN = -1,
|
UNKNOWN = -1,
|
||||||
ALL_FORMATS = 0,
|
ALL_FORMATS = 0,
|
||||||
@ -96,6 +130,8 @@ export interface Barcode {
|
|||||||
rawValue: string
|
rawValue: string
|
||||||
displayValue: string
|
displayValue: string
|
||||||
cornerPoints: any
|
cornerPoints: any
|
||||||
|
imageHeight: number
|
||||||
|
imageWidth: number
|
||||||
email: BarcodeEmail
|
email: BarcodeEmail
|
||||||
phone: BarcodePhone
|
phone: BarcodePhone
|
||||||
sms: BarcodeSms
|
sms: BarcodeSms
|
||||||
@ -180,6 +216,11 @@ export interface BarcodeDriverLicense {
|
|||||||
issuingCountry: string
|
issuingCountry: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ImageLabel {
|
||||||
|
index: number,
|
||||||
|
confidence: number,
|
||||||
|
text: string
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @name Firebase Vision
|
* @name Firebase Vision
|
||||||
* @description
|
* @description
|
||||||
@ -203,6 +244,10 @@ export interface BarcodeDriverLicense {
|
|||||||
* .then((res: Barcode[]) => console.log(res))
|
* .then((res: Barcode[]) => console.log(res))
|
||||||
* .catch((error: string) => console.error(error));
|
* .catch((error: string) => console.error(error));
|
||||||
*
|
*
|
||||||
|
* this.firebaseVision.imageLabeler(FILE_URI)
|
||||||
|
* .then((res: ImageLabel[]) => console.log(res))
|
||||||
|
* .catch((error: string) => console.error(error));
|
||||||
|
*
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@Plugin({
|
@Plugin({
|
||||||
@ -220,12 +265,25 @@ export class FirebaseVision extends IonicNativePlugin {
|
|||||||
* @return {Promise<string>} Returns a promise that fulfills with the text in the image
|
* @return {Promise<string>} Returns a promise that fulfills with the text in the image
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
onDeviceTextRecognizer(file_uri: string): Promise<string> {
|
onDeviceTextRecognizer(file_uri: string): Promise<Text> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Read data from Barcode
|
||||||
|
* @param file_uri {string} Image URI
|
||||||
|
* @return {Promise<Barcode[]>} Returns a promise that fulfills with the data in barcode
|
||||||
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
barcodeDetector(file_uri: string): Promise<Barcode[]> {
|
barcodeDetector(file_uri: string): Promise<Barcode[]> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Recognize object in image
|
||||||
|
* @param file_uri {string} Image URI
|
||||||
|
* @return {Promise<ImageLabel[]>} Returns a promise that fulfills with the information about entities in an image
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
imageLabeler(file_uri: string): Promise<ImageLabel[]> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user