qt-human 2.3.5-alpha → 2.3.7-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { QuanTe as QuanTe$2 } from '@/types';
11
11
  import Recorder from 'recorder-core';
12
12
  import { IResultData as IResultData$1 } from '@/api/interface';
13
13
  import FramePlayer from '@/utils/framePlayer';
14
- import { CameraConfig as CameraConfig$1 } from '@/types/camera';
14
+ import { CameraConfig as CameraConfig$1, FaceRecognitionConfig as FaceRecognitionConfig$1 } from '@/types/camera';
15
15
 
16
16
  type ActionObjType = {
17
17
  action: THREE.AnimationAction;
@@ -273,7 +273,7 @@ declare class VoiceInteraction extends Emittery {
273
273
  private wakeWordDetection;
274
274
  private exitWordDetection;
275
275
  private interruptWordDetection;
276
- onWakeDetected(): void;
276
+ onWakeDetected(echo?: any): void;
277
277
  onSleepDetected(): void;
278
278
  private onInterruptDetected;
279
279
  destroy(): void;
@@ -289,19 +289,35 @@ interface CameraConfig {
289
289
  overlayImage?: HTMLImageElement | null; // 合影 PNG
290
290
  }
291
291
 
292
- type ProximityState = 'near' | 'far' | 'stable';
292
+ interface FaceRecognitionConfig {
293
+ // 多长时间识别一次 单位 ms, 默认 3000ms
294
+ duration?: number;
295
+ // 识别人数 默认 不限
296
+ maxResults?: number;
297
+ // 是否在视频上绘制人脸检测框,默认 false
298
+ drawDetections?: boolean;
299
+ // 是否在视频上绘制人脸特征点,默认 false
300
+ drawFaceLandmarks?: boolean;
301
+ // 最小置信度,默认 0.6
302
+ minConfidence?: number;
303
+ }
293
304
 
305
+ type ProximityState = 'near' | 'far' | 'stable';
294
306
  declare class CameraSDK {
295
307
  private manager;
296
308
  private features;
297
309
  private container;
298
310
  private video;
299
311
  constructor(config: CameraConfig);
300
- open(): Promise<void>;
312
+ open(): Promise<boolean>;
313
+ isOpen(): boolean;
301
314
  close(): void;
302
315
  takePhoto(): Promise<string>;
303
316
  switchCamera(facingMode: "user" | "environment"): Promise<void>;
304
- detectPose(callback: (stable: ProximityState) => void): Promise<void>;
317
+ startFaceRecognition(config: FaceRecognitionConfig, callback: Function): Promise<boolean>;
318
+ stopFaceRecognition(): Promise<boolean>;
319
+ startBodyDetect(callback: (stable: ProximityState) => void): Promise<boolean>;
320
+ stopBodyDetect(): Promise<boolean>;
305
321
  destroy(): void;
306
322
  }
307
323
 
@@ -375,7 +391,11 @@ declare class Human extends Emittery implements QuanTe$1.Human {
375
391
  closeRecorder(): Promise<boolean>;
376
392
  openRecorder(): Promise<QuanTe$1.Result<QuanTe$1.Recorder.PermissionResult>>;
377
393
  openCamera(config: CameraConfig$1): Promise<boolean>;
378
- wakeUp(isWake?: boolean): Promise<void>;
394
+ wakeUp(isWake: boolean | undefined, echo: any): Promise<void>;
395
+ startFaceRecognition(config?: FaceRecognitionConfig$1): Promise<boolean>;
396
+ stopFaceRecognition(): Promise<boolean>;
397
+ startBodyDetect(): Promise<boolean>;
398
+ stopBodyDetect(): Promise<boolean>;
379
399
  }
380
400
 
381
401
  declare namespace QuanTe {
@@ -488,6 +508,10 @@ declare namespace QuanTe {
488
508
  public openRecorder(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>
489
509
  // 打开摄像头
490
510
  public openCamera(config: CameraConfig): Promise<boolean>
511
+ public startFaceRecognition(config: FaceRecognitionConfig): Promise<boolean>
512
+ public stopFaceRecognition(): Promise<boolean>
513
+ public startBodyDetect(): Promise<boolean>
514
+ public stopBodyDetect(): Promise<boolean>
491
515
  }
492
516
 
493
517
  export interface ModelInfo {
@@ -1074,7 +1098,9 @@ declare enum EmitEvent {
1074
1098
  // 播放音频
1075
1099
  AUDIO_PLAY = 'audio.play',
1076
1100
  // 摄像机人体检测结果
1077
- CAMERA_PERSON_TEST_RESULT = 'camera.person.test.result'
1101
+ CAMERA_PERSON_TEST_RESULT = 'camera.person.test.result',
1102
+ // 摄像机人脸识别结果
1103
+ CAMERA_FACE_RECOGNITION_RESULT = 'camera.face.recognition.result'
1078
1104
  }
1079
1105
 
1080
1106
  export { EmitEvent, QuanTe, Human as default };
@@ -0,0 +1,2 @@
1
+ import { IResultData } from './interface';
2
+ export declare const faceRecognitionApi: (blob: Blob) => Promise<IResultData<any>>;
@@ -0,0 +1,13 @@
1
+ import type { CameraFeature, CameraCore, FaceRecognitionConfig } from "../../types/camera";
2
+ export declare class FaceFeature implements CameraFeature {
3
+ name: string;
4
+ isInitialized: boolean;
5
+ private interval;
6
+ constructor();
7
+ initFaceAPI(): Promise<void>;
8
+ startFaceRecognition(camera: CameraCore, config: FaceRecognitionConfig, callback: Function): Promise<boolean>;
9
+ private expandBox;
10
+ private cropFaceToBase64;
11
+ private cropFaceToBlob;
12
+ stopFaceRecognition(): Promise<boolean>;
13
+ }
@@ -1,15 +1,19 @@
1
- import type { CameraConfig } from "../../types/camera";
2
- import { ProximityState } from './proximityDetector';
1
+ import type { CameraConfig, FaceRecognitionConfig } from "../../types/camera";
2
+ export type ProximityState = 'near' | 'far' | 'stable';
3
3
  export declare class CameraSDK {
4
4
  private manager;
5
5
  private features;
6
6
  private container;
7
7
  private video;
8
8
  constructor(config: CameraConfig);
9
- open(): Promise<void>;
9
+ open(): Promise<boolean>;
10
+ isOpen(): boolean;
10
11
  close(): void;
11
12
  takePhoto(): Promise<string>;
12
13
  switchCamera(facingMode: "user" | "environment"): Promise<void>;
13
- detectPose(callback: (stable: ProximityState) => void): Promise<void>;
14
+ startFaceRecognition(config: FaceRecognitionConfig, callback: Function): Promise<boolean>;
15
+ stopFaceRecognition(): Promise<boolean>;
16
+ startBodyDetect(callback: (stable: ProximityState) => void): Promise<boolean>;
17
+ stopBodyDetect(): Promise<boolean>;
14
18
  destroy(): void;
15
19
  }
@@ -4,9 +4,10 @@ export declare class MediaStreamManager implements CameraCore {
4
4
  private stream;
5
5
  private facingMode;
6
6
  constructor(video: HTMLVideoElement, facingMode?: FacingMode);
7
- open(): Promise<void>;
7
+ open(): Promise<boolean>;
8
8
  close(): void;
9
- switch(facingMode: FacingMode): Promise<void>;
9
+ switch(facingMode: FacingMode): Promise<boolean>;
10
10
  getVideoEl(): HTMLVideoElement;
11
11
  getStream(): MediaStream | null;
12
+ isOpen(): boolean;
12
13
  }
@@ -37,7 +37,7 @@ declare class VoiceInteraction extends Emittery {
37
37
  private wakeWordDetection;
38
38
  private exitWordDetection;
39
39
  private interruptWordDetection;
40
- onWakeDetected(): void;
40
+ onWakeDetected(echo?: any): void;
41
41
  onSleepDetected(): void;
42
42
  private onInterruptDetected;
43
43
  destroy(): void;
@@ -6,7 +6,7 @@ import type { QuanTe } from '@/types/index';
6
6
  import { IResultData } from '@/api/interface';
7
7
  import voiceInteraction from './core/voice-interaction';
8
8
  import FramePlayer from '@/utils/framePlayer';
9
- import { CameraConfig } from '@/types/camera';
9
+ import { CameraConfig, FaceRecognitionConfig } from '@/types/camera';
10
10
  import { CameraSDK } from './camera';
11
11
  declare class Human extends Emittery implements QuanTe.Human {
12
12
  name: string;
@@ -78,7 +78,11 @@ declare class Human extends Emittery implements QuanTe.Human {
78
78
  closeRecorder(): Promise<boolean>;
79
79
  openRecorder(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>;
80
80
  openCamera(config: CameraConfig): Promise<boolean>;
81
- wakeUp(isWake?: boolean): Promise<void>;
81
+ wakeUp(isWake: boolean | undefined, echo: any): Promise<void>;
82
+ startFaceRecognition(config?: FaceRecognitionConfig): Promise<boolean>;
83
+ stopFaceRecognition(): Promise<boolean>;
84
+ startBodyDetect(): Promise<boolean>;
85
+ stopBodyDetect(): Promise<boolean>;
82
86
  }
83
87
  export default Human;
84
88
  export type { QuanTe };
@@ -16,4 +16,17 @@ export interface CameraFeature {
16
16
  export interface CameraCore {
17
17
  getVideoEl(): HTMLVideoElement;
18
18
  getStream(): MediaStream | null;
19
+ }
20
+
21
+ export interface FaceRecognitionConfig {
22
+ // 多长时间识别一次 单位 ms, 默认 3000ms
23
+ duration?: number;
24
+ // 识别人数 默认 不限
25
+ maxResults?: number;
26
+ // 是否在视频上绘制人脸检测框,默认 false
27
+ drawDetections?: boolean;
28
+ // 是否在视频上绘制人脸特征点,默认 false
29
+ drawFaceLandmarks?: boolean;
30
+ // 最小置信度,默认 0.6
31
+ minConfidence?: number;
19
32
  }
@@ -17,5 +17,6 @@ export declare enum EmitEvent {
17
17
  WAKE_RECORDER_STOP = "wake.record.stop",
18
18
  AUDIO_PAUSE = "audio.pause",
19
19
  AUDIO_PLAY = "audio.play",
20
- CAMERA_PERSON_TEST_RESULT = "camera.person.test.result"
20
+ CAMERA_PERSON_TEST_RESULT = "camera.person.test.result",
21
+ CAMERA_FACE_RECOGNITION_RESULT = "camera.face.recognition.result"
21
22
  }
@@ -36,5 +36,7 @@ export enum EmitEvent {
36
36
  // 播放音频
37
37
  AUDIO_PLAY = 'audio.play',
38
38
  // 摄像机人体检测结果
39
- CAMERA_PERSON_TEST_RESULT = 'camera.person.test.result'
39
+ CAMERA_PERSON_TEST_RESULT = 'camera.person.test.result',
40
+ // 摄像机人脸识别结果
41
+ CAMERA_FACE_RECOGNITION_RESULT = 'camera.face.recognition.result'
40
42
  }
@@ -1,7 +1,7 @@
1
1
  import { API } from "./api";
2
2
  import * as THREE from 'three'
3
3
  import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
4
- import { CameraConfig } from "./camera";
4
+ import { CameraConfig, FaceRecognitionConfig } from "./camera";
5
5
 
6
6
  export namespace QuanTe {
7
7
  export type Character = 'xiaomeng' | 'custom' | 'quan' | 'doctor' | 'boy' | 'girl' | '';
@@ -113,6 +113,10 @@ export namespace QuanTe {
113
113
  public openRecorder(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>
114
114
  // 打开摄像头
115
115
  public openCamera(config: CameraConfig): Promise<boolean>
116
+ public startFaceRecognition(config: FaceRecognitionConfig): Promise<boolean>
117
+ public stopFaceRecognition(): Promise<boolean>
118
+ public startBodyDetect(): Promise<boolean>
119
+ public stopBodyDetect(): Promise<boolean>
116
120
  }
117
121
 
118
122
  export interface ModelInfo {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qt-human",
3
- "version": "2.3.5-alpha",
3
+ "version": "2.3.7-alpha",
4
4
  "main": "dist/bundle.umd.js",
5
5
  "module": "dist/bundle.esm.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -59,11 +59,11 @@
59
59
  "dependencies": {
60
60
  "@mediapipe/pose": "^0.5.1675469404",
61
61
  "@tensorflow-models/pose-detection": "^2.1.3",
62
- "@tensorflow/tfjs-backend-cpu": "^4.22.0",
63
62
  "@tensorflow/tfjs-backend-webgl": "^4.22.0",
64
63
  "@tensorflow/tfjs-backend-webgpu": "^4.22.0",
65
64
  "@tensorflow/tfjs-converter": "^4.22.0",
66
65
  "@tensorflow/tfjs-core": "^4.22.0",
66
+ "@vladmandic/face-api": "^1.7.15",
67
67
  "axios": "^1.7.2",
68
68
  "crypto-js": "^4.2.0",
69
69
  "emittery": "^1.0.3",