diff --git a/src/ext/extra-types/match-detection-types.ts b/src/ext/extra-types/match-detection-types.ts new file mode 100644 index 0000000..df41a3c --- /dev/null +++ b/src/ext/extra-types/match-detection-types.ts @@ -0,0 +1,85 @@ +import { DetectionQuality, FaceQualityScenarios, FaceSDKResult, ImageData } from "../../models"; + +type TDetection = { + /** + * + * @type {ImageData} + * @memberof Detection + */ + 'crop'?: ImageData; + /** + * + * @memberof Detection + */ + 'attributes'?: { + /** + * + * @type {Array<{ name?: string; confidence?: number; value?: any; }>} + */ + 'details'?: { name?: string; confidence?: number; value?: any; }[]; + /** + * The elapsed time for attribute detection. + * @type {number} + */ + 'elapsedTime'?: number; + }; + /** + * Absolute coordinates (x,y) of five points of each detected face: left eye, right eye, nose, left point of lips, right point of lips. + * @type {Array>} + * @memberof Detection + */ + 'landmarks': Array>; + /** + * + * @type {DetectionQuality} + * @memberof Detection + */ + 'quality'?: DetectionQuality; + /** + * The rectangular area of a detected face that is represented by a set of four elements: the X and Y coordinates of the top-left point, and the width and height dimensions of the rectangle. + * @type {Array} + * @memberof Detection + */ + 'roi': Array; + /** + * Base64 of the cropped portrait. + * @type {string} + * @memberof Detection + */ + 'thumbnail'?: string; +} + +export type TDetectResponse = { + results?: { + /** + * + * @type {Array} + * @memberof DetectResult + */ + 'detections': Array; + /** + * Internal. + * @type {number} + * @memberof DetectResult + */ + 'detectorType'?: number; + /** + * Internal. + * @type {number} + * @memberof DetectResult + */ + 'landmarksType'?: number; + /** + * + * @type {FaceQualityScenarios} + * @memberof DetectResult + */ + 'scenario'?: FaceQualityScenarios; + /** + * The total time taken for the detection. + * @type {number} + * @memberof DetectResult + */ + 'timer'?: number; + } +} & FaceSDKResult; \ No newline at end of file diff --git a/src/ext/matching-api.ts b/src/ext/matching-api.ts index 474b722..d5877ce 100755 --- a/src/ext/matching-api.ts +++ b/src/ext/matching-api.ts @@ -1,8 +1,9 @@ import { MatchingApi as GenMatchingApi } from '../api/matching-api'; -import { MatchRequest, DetectRequest, ImageSource, MatchResponse, DetectResponse } from '../models'; +import { MatchRequest, DetectRequest, ImageSource, MatchResponse } from '../models'; import { AxiosRequestConfig, AxiosInstance } from 'axios'; import { Configuration } from '../configuration'; import * as converter from 'base64-arraybuffer'; +import { TDetectResponse } from './extra-types/match-detection-types'; export class MatchingApi { private superClass: GenMatchingApi; @@ -30,12 +31,12 @@ export class MatchingApi { detectRequest: DetectRequest, xRequestID?: string, options?: AxiosRequestConfig, - ): Promise { + ): Promise { if (detectRequest.image && typeof detectRequest.image !== 'string') { detectRequest.image = converter.encode(detectRequest.image); } const response = await this.superClass.detect(detectRequest, xRequestID, options); - return response.data; + return response.data as TDetectResponse; } } diff --git a/src/models/index.ts b/src/models/index.ts index 5dab152..d7211a9 100755 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -25,6 +25,7 @@ export * from './group-page'; export * from './group-page-all-of'; export * from './group-to-create'; export * from './image'; +export * from './image-data'; export * from './image-fields'; export * from './image-fields-image'; export * from './image-page';