Skip to content

Commit 2bcbfb9

Browse files
Merge pull request #76 from regulaforensics/fix/sp-11788
SP-11788 - fix detection model through extra types
2 parents ed1bc1f + 7923c8a commit 2bcbfb9

File tree

3 files changed

+90
-3
lines changed

3 files changed

+90
-3
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { DetectionQuality, FaceQualityScenarios, FaceSDKResult, ImageData } from "../../models";
2+
3+
type TDetection = {
4+
/**
5+
*
6+
* @type {ImageData}
7+
* @memberof Detection
8+
*/
9+
'crop'?: ImageData;
10+
/**
11+
*
12+
* @memberof Detection
13+
*/
14+
'attributes'?: {
15+
/**
16+
*
17+
* @type {Array<{ name?: string; confidence?: number; value?: any; }>}
18+
*/
19+
'details'?: { name?: string; confidence?: number; value?: any; }[];
20+
/**
21+
* The elapsed time for attribute detection.
22+
* @type {number}
23+
*/
24+
'elapsedTime'?: number;
25+
};
26+
/**
27+
* Absolute coordinates (x,y) of five points of each detected face: left eye, right eye, nose, left point of lips, right point of lips.
28+
* @type {Array<Array<number>>}
29+
* @memberof Detection
30+
*/
31+
'landmarks': Array<Array<number>>;
32+
/**
33+
*
34+
* @type {DetectionQuality}
35+
* @memberof Detection
36+
*/
37+
'quality'?: DetectionQuality;
38+
/**
39+
* 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.
40+
* @type {Array<number>}
41+
* @memberof Detection
42+
*/
43+
'roi': Array<number>;
44+
/**
45+
* Base64 of the cropped portrait.
46+
* @type {string}
47+
* @memberof Detection
48+
*/
49+
'thumbnail'?: string;
50+
}
51+
52+
export type TDetectResponse = {
53+
results?: {
54+
/**
55+
*
56+
* @type {Array<Detection>}
57+
* @memberof DetectResult
58+
*/
59+
'detections': Array<TDetection>;
60+
/**
61+
* Internal.
62+
* @type {number}
63+
* @memberof DetectResult
64+
*/
65+
'detectorType'?: number;
66+
/**
67+
* Internal.
68+
* @type {number}
69+
* @memberof DetectResult
70+
*/
71+
'landmarksType'?: number;
72+
/**
73+
*
74+
* @type {FaceQualityScenarios}
75+
* @memberof DetectResult
76+
*/
77+
'scenario'?: FaceQualityScenarios;
78+
/**
79+
* The total time taken for the detection.
80+
* @type {number}
81+
* @memberof DetectResult
82+
*/
83+
'timer'?: number;
84+
}
85+
} & FaceSDKResult;

src/ext/matching-api.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { MatchingApi as GenMatchingApi } from '../api/matching-api';
2-
import { MatchRequest, DetectRequest, ImageSource, MatchResponse, DetectResponse } from '../models';
2+
import { MatchRequest, DetectRequest, ImageSource, MatchResponse } from '../models';
33
import { AxiosRequestConfig, AxiosInstance } from 'axios';
44
import { Configuration } from '../configuration';
55
import * as converter from 'base64-arraybuffer';
6+
import { TDetectResponse } from './extra-types/match-detection-types';
67

78
export class MatchingApi {
89
private superClass: GenMatchingApi;
@@ -30,12 +31,12 @@ export class MatchingApi {
3031
detectRequest: DetectRequest,
3132
xRequestID?: string,
3233
options?: AxiosRequestConfig,
33-
): Promise<DetectResponse> {
34+
): Promise<TDetectResponse> {
3435
if (detectRequest.image && typeof detectRequest.image !== 'string') {
3536
detectRequest.image = converter.encode(detectRequest.image);
3637
}
3738

3839
const response = await this.superClass.detect(detectRequest, xRequestID, options);
39-
return response.data;
40+
return response.data as TDetectResponse;
4041
}
4142
}

src/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export * from './group-page';
2525
export * from './group-page-all-of';
2626
export * from './group-to-create';
2727
export * from './image';
28+
export * from './image-data';
2829
export * from './image-fields';
2930
export * from './image-fields-image';
3031
export * from './image-page';

0 commit comments

Comments
 (0)