Seeking a TypeScript definition file for the Google Vision API

Could someone point me in the direction of a TypeScript definition file for the Google Vision API? I've searched but can't seem to find one. Do they even exist, or will I have to make my own?

Answer №1

I've recently delved into creating my own set of TypeScript interfaces specifically tailored for the Google Vision API.

Here's a glimpse of what I've managed to put together so far:

/**
 * Custom Interfaces for 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;
}

/**
 * Work in progress - Not finalized yet
 */
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;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Developing a custom camera system for a top-down RPG game using Javascript Canvas

What specific question do I have to ask now? My goal is to implement a "viewport" camera effect that will track the player without moving the background I am integrating websocket support and planning to render additional characters on the map - movement ...

There seems to be an issue with my React application that was built using Webpack 5 and compiled with TypeScript. The @tailwind directive is not functioning properly in the browser, and

As I embark on creating a fresh react application using Webpack 5, Tailwind CSS, and Typescript, I find myself at a crossroads. Despite piecing together various tutorials, I am struggling to configure the postcss-loader for Tailwind. While traditional .css ...

Mastering the art of connecting content within Prismic

I have been working on creating a mega menu for my website header, but I am encountering a type error. Has anyone else faced this issue before and how did you resolve it? I am currently importing the generated types from @/prismicio-types. Here is an exam ...

Anticipate receiving a 'Type' returned by external library functions

I've recently started learning TypeScript and have encountered a situation where I need to assign a type to a variable that is returned from a third-party library function with its own type definition. For instance: import {omit} from 'lodash&ap ...

Is Typescript the Ultimate Replacement for propTypes in React Development?

After diving into Typescript for the first time and exploring related articles, it appears that when using Typescript with React, propTypes definitions may no longer be necessary. However, upon examining some of the most popular React Component Libraries: ...

What type of map is able to be indexed by a combination of strings and output a numerical value?

I am working with a type that is a combination of strings: type MatchType = | "first" | "second" | "third" My goal is to create a map that uses this type as an index and returns a corresponding number: let numValue = 3 let myMap: NumberMap = ...

Issue with TypeScript when using destructuring on an object

When attempting to destructure data from an object, I encountered the error message Property XXXX does not exist on type unknown. This issue arose while using React Router to retrieve data. let {decoded, reasonTypes, submissionDetails} = useRouteLoaderDa ...

Guide on calculating the total of an object's attributes in Angular

Given a JSON object structured as follows: { "baskets": [{ "id": 127, "name": "name 1", "kpIs": [{ "id": 419, "name": var a1, "incentive": 0, "ta ...

Using React with Typescript to iterate through a list of countries in order to generate a dropdown selection menu

In the file countries.tsx, I have stored a list of countries along with their ISO codes... // countries.tsx export const COUNTRIES: { [x: string]: { [y: string]: string } } = { en: { AX: 'Aaland Islands', AF: 'Afghanistan', ...

"Compilation errors encountered when trying to build Typescript within a Azure Function App running in

Currently, I am in the process of deploying to an Azure Function App from a container that resides inside Azure Container Registry. To begin with, I utilized the func init command (selected the typescript option) and incorporated some code using the servi ...

Define the type of Axios response when making a post request with a body

I am encountering an issue where I need to specify both the JSON body and the response type separately, as they are different. Some examples I've seen have them set to be the same. Here is the error message I received: Argument of type '{ gran ...

Managing state in React using useEffect and useState - Avoiding undefined values

Encountering the same undefined error in various components. After verifying that the data is coming from the API, not blocked by CORS, and accessible in the useEffect callback, it appears that the issue lies in setting the state. I attempted to replace th ...

In the latest version of Angular, accessing document.getelementbyid consistently returns null

I am struggling with a component that looks like this export class NotificationPostComponent extends PostComponent implements OnInit, AfterViewInit { commentsDto: IComment[] = []; commentId = ''; ngOnInit(): void { this.route.data ...

Can we create an intersection type of Records by pairing keys with tuples or unions of values in a one-to-one correspondence?

If I have tuples similar to this for keys and values: type Keys = ['North', 'East', 'South', 'West']; type Values = ['n', 'e', 's', 'w']; Is there a way to achieve a structure ...

Update the checkbox value to a string

I have come across many questions regarding changing the value of a checkbox to a string, but I am still facing difficulties. Specifically, I need to change the value from true - false to 'A' - 'B'. My code is based on reactive forms in ...

Errors arose due to the deployment of TypeScript decorators

Using TypeScript in a brand new ASP.NET Core project has brought some challenges. We are actively incorporating decorators into our codebase. However, this integration is causing numerous errors to appear in the output of VS2015: Error TS1219 Experim ...

Step-by-step guide on uploading a file for API testing

When working on API integration tests using playwright, I encounter a scenario where I need to call an API that uploads a file. In my project directory, there is a folder dedicated to static assets which contains the following file: /static-assets - im ...

Tips for effectively utilizing the 'or' operator when working with disparate data types

One of my functions requires an argument that can have one of two different types. If you're interested in TypeScript functions and types, take a look at the official documentation, as well as these Stack Overflow questions: Question 1 and Question 2 ...

Reducing the storage footprint of the gcloud CLI setup

I am facing a challenge with my server admin restricting the disk space to around 50 Mb, while the default gcloud install (including alpha) on Linux requires about 150 Mb. To make it fit within my limited drive space, I have attempted various methods. One ...

Why is the lifecycle callback not being triggered?

I am currently learning how to develop with Vue.js. I have been trying to use the lifecycle callbacks in my code. In my App.vue file, I have implemented the onMounted callback. However, when I run the code, I do not see the message appearing in the consol ...