Skip to content

Commit

Permalink
Merge pull request #76 from regulaforensics/fix/sp-11788
Browse files Browse the repository at this point in the history
SP-11788 - fix detection model through extra types
  • Loading branch information
SergeyIlchenko authored Nov 8, 2023
2 parents ed1bc1f + 7923c8a commit 2bcbfb9
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 3 deletions.
85 changes: 85 additions & 0 deletions src/ext/extra-types/match-detection-types.ts
Original file line number Diff line number Diff line change
@@ -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<Array<number>>}
* @memberof Detection
*/
'landmarks': Array<Array<number>>;
/**
*
* @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<number>}
* @memberof Detection
*/
'roi': Array<number>;
/**
* Base64 of the cropped portrait.
* @type {string}
* @memberof Detection
*/
'thumbnail'?: string;
}

export type TDetectResponse = {
results?: {
/**
*
* @type {Array<Detection>}
* @memberof DetectResult
*/
'detections': Array<TDetection>;
/**
* 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;
7 changes: 4 additions & 3 deletions src/ext/matching-api.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -30,12 +31,12 @@ export class MatchingApi {
detectRequest: DetectRequest,
xRequestID?: string,
options?: AxiosRequestConfig,
): Promise<DetectResponse> {
): Promise<TDetectResponse> {
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;
}
}
1 change: 1 addition & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 2bcbfb9

Please sign in to comment.