寻找Google Vision API TypeScript定义文件

时间:2019-02-15 00:03:30

标签: typescript google-cloud-platform computer-vision typescript-typings

我正在寻找Google Vision API TypeScript定义文件,但未找到任何文件。 它们存在还是我必须创建自己的?

1 个答案:

答案 0 :(得分:1)

我已经开始为TypeScript interfaces开发Google Vision API。

这是我到目前为止所拥有的:

/**
 * Interfaces used in Google Vision API results
 */
export interface IPoint2D {
    x: number;
    y: number;
}

export interface IPoint3D {
    x: number;
    y: number;
    z: number;
}

export interface IFaceFeature {
    type: string;
    position: IPoint3D;
}

export interface IVertex2Array {
    vertices: IPoint2D[];
    normalizedVertices?: any;
}

/**
 * Not sure if this is complete
 */
type StringLikelihood = "VERY_UNLIKELY" | "UNLIKELY" | "POSSIBLE" | "LIKELY" | "VERY_LIKELY";

export interface IFaceAnnotation {
    landmark: IFaceFeature[];
    boundingPoly: any[];
    fdBoundingPoly: any[];
    rollAngle: number;
    panAngle: number;
    tiltAngle: number;
    detectionConfidence: number;
    landmarkingConfidence: number;
    joyLikelihood: StringLikelihood;
    sorrowLikelihood: StringLikelihood;
    angerLikelihood: StringLikelihood;
    surpriseLikelihood: StringLikelihood;
    underExposedLikelihood: StringLikelihood;
    blurredLikelihood: StringLikelihood;
    headwearLikelihood: StringLikelihood;
}

export interface ILabelAnnotations {
    locations: any[];
    properties: any[];
    mid: string;
    locale: string;
    description: string;
    score: number;
    confidence: number;
    topicality: number;
    boundingPoly: any;
  }

export interface IApiVisionResponse {
    faceAnnotations: IFaceAnnotation[];
    landmarkAnnotations: any[];
    logoAnnotations: any[];
    labelAnnotations: ILabelAnnotations[];
    textAnnotations: any[];
    localizedObjectAnnotations: any[];
    safeSearchAnnotation: any;
    imagePropertiesAnnotation: any;
    error: any;
    cropHintsAnnotation: any;
    fullTextAnnotation: any;
    webDetection: any;
    productSearchResults: any;
    context: any;
}