shared-ritm 1.2.74 → 1.2.76
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/README.md +103 -103
- package/dist/index.css +1 -1
- package/dist/shared-ritm.es.js +16 -16
- package/dist/shared-ritm.umd.js +9 -9
- package/dist/types/api/services/TasksService.d.ts +3 -3
- package/dist/types/api/types/Api_Tasks.d.ts +54 -23
- package/dist/types/api/types/Api_Users.d.ts +43 -0
- package/package.json +64 -64
- package/src/api/services/PhotoService.ts +137 -137
- package/src/api/services/RepairsService.ts +119 -119
- package/src/api/services/TasksService.ts +4 -4
- package/src/api/services/UserService.ts +19 -19
- package/src/api/types/Api_Controls.ts +72 -72
- package/src/api/types/Api_Files.ts +1 -1
- package/src/api/types/Api_Instruments.ts +98 -98
- package/src/api/types/Api_Projects.ts +55 -55
- package/src/api/types/Api_Repairs.ts +115 -115
- package/src/api/types/Api_Tasks.ts +59 -25
- package/src/api/types/Api_User.ts +44 -44
- package/src/common/app-checkbox/AppCheckbox.vue +26 -26
- package/src/common/app-datepicker/AppDatepicker.vue +165 -165
- package/src/common/app-dialogs/AppConfirmDialog.vue +99 -99
- package/src/common/app-dropdown/AppDropdown.vue +31 -31
- package/src/common/app-input/AppInput.vue +148 -148
- package/src/common/app-input-new/AppInputNew.vue +152 -152
- package/src/common/app-select/AppSelect.vue +157 -157
- package/src/common/app-sheet/AppSheet.vue +120 -120
- package/src/common/app-sidebar/components/SidebarMenuItem.vue +148 -148
- package/src/common/app-table/AppTable.vue +297 -297
- package/src/common/app-table/AppTableLayout.vue +111 -111
- package/src/common/app-table/components/ModalSelect.vue +270 -270
- package/src/common/app-table/components/TableModal.vue +329 -329
- package/src/common/app-table/components/TablePagination.vue +152 -152
- package/src/common/app-table/components/TableSearch.vue +76 -76
- package/src/common/app-table/controllers/useBaseTable.ts +42 -42
- package/src/common/app-table/controllers/useColumnSelector.ts +38 -38
- package/src/common/app-table/controllers/useTableModel.ts +93 -93
- package/src/common/app-toggle/AppToggle.vue +24 -24
- package/src/common/app-wrapper/AppWrapper.vue +28 -28
- package/src/icons/components/table-filter-icon.vue +30 -30
- package/src/icons/dialogs/RemoveIcon.vue +12 -12
- package/src/icons/dialogs/SafetyIcon.vue +12 -12
- package/src/icons/task/attention-icon.vue +13 -13
- package/src/icons/task/clock-icon.vue +10 -10
- package/src/icons/task/delete-icon.vue +10 -10
- package/src/icons/task/fire-icon.vue +16 -16
- package/src/index.ts +103 -103
- package/src/main.ts +28 -28
- package/src/shared/styles/general.css +125 -125
- package/src/styles/variables.sass +12 -12
- package/src/utils/confirm.ts +12 -12
- package/src/utils/helpers.ts +58 -58
- package/src/utils/notification.ts +9 -9
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import ApiService from '@/api/settings/ApiService';
|
|
2
2
|
import { ResponseApi } from '@/api/types/Api_Service';
|
|
3
|
-
import { Api_Task_Close_Reason, Api_Task_Instrument_Dto, Api_Task_Instrument_From_Warehouse, Api_Task_Module_Instrument_Condition,
|
|
3
|
+
import { Api_Task_Close_Reason, Api_Task_Instrument_Dto, Api_Task_Instrument_From_Warehouse, Api_Task_Module_Instrument_Condition, Api_Task_DTO, Api_Tasks_Task_Dto } from '@/api/types/Api_Tasks';
|
|
4
4
|
import { Api_Equipment_Full_Dto, Api_Task_Video_Source, Api_Task_Video_Source_Stream } from '@/api/types/Api_Repairs';
|
|
5
5
|
declare class TasksService extends ApiService {
|
|
6
6
|
fetchTaskById(id: string): Promise<ResponseApi<Api_Tasks_Task_Dto>>;
|
|
7
|
-
fetchTasksList(params: any): Promise<ResponseApi<
|
|
8
|
-
fetchSubtasksList(id: string): Promise<ResponseApi<
|
|
7
|
+
fetchTasksList(params: any): Promise<ResponseApi<Api_Task_DTO[]>>;
|
|
8
|
+
fetchSubtasksList(id: string): Promise<ResponseApi<Api_Task_DTO[]>>;
|
|
9
9
|
fetchTaskBranch(id: string): Promise<ResponseApi<any>>;
|
|
10
10
|
fetchInstrumentsList(params: any): Promise<ResponseApi<any[]>>;
|
|
11
11
|
fetchInstrumentTypeListWithPreparedWarehouse(params: {
|
|
@@ -91,29 +91,6 @@ export type Api_Tasks_Task_Dto = {
|
|
|
91
91
|
isPause: boolean;
|
|
92
92
|
equipment: Api_Tasks_Equipment_Dto[];
|
|
93
93
|
};
|
|
94
|
-
export type Api_Tasks_Simple_Responsible_Dto = {
|
|
95
|
-
id: string;
|
|
96
|
-
full_name: string;
|
|
97
|
-
};
|
|
98
|
-
export type Api_Tasks_Dto = {
|
|
99
|
-
id: string;
|
|
100
|
-
name: string;
|
|
101
|
-
plan_date: null | string;
|
|
102
|
-
deadline: null | string;
|
|
103
|
-
priority: number;
|
|
104
|
-
subtasks_count: number;
|
|
105
|
-
responsible: Api_Tasks_Simple_Responsible_Dto[];
|
|
106
|
-
assigned: any[];
|
|
107
|
-
status: Api_Tasks_Status_Dto;
|
|
108
|
-
expired: boolean;
|
|
109
|
-
teams: Api_Tasks_Teams_Dto[];
|
|
110
|
-
is_critical_path: boolean;
|
|
111
|
-
isPause: boolean;
|
|
112
|
-
fact_start_date: null | string;
|
|
113
|
-
fact_end_date: null | string;
|
|
114
|
-
pause_sec: number;
|
|
115
|
-
work_sec: number;
|
|
116
|
-
};
|
|
117
94
|
export type Api_Task_Instrument_Dto = {
|
|
118
95
|
id: string;
|
|
119
96
|
name: string;
|
|
@@ -138,3 +115,57 @@ export type Api_Task_Close_Reason = {
|
|
|
138
115
|
has_reason: boolean;
|
|
139
116
|
category: string;
|
|
140
117
|
};
|
|
118
|
+
export type Api_Assigned_DTO = {
|
|
119
|
+
id: string;
|
|
120
|
+
first_name: string;
|
|
121
|
+
last_name: string;
|
|
122
|
+
patronymic: string;
|
|
123
|
+
full_name: string;
|
|
124
|
+
};
|
|
125
|
+
export type Api_Status_DTO = {
|
|
126
|
+
id: string;
|
|
127
|
+
name: string;
|
|
128
|
+
title: string;
|
|
129
|
+
};
|
|
130
|
+
export type Api_Teams_DTO = {
|
|
131
|
+
id: string;
|
|
132
|
+
name: string;
|
|
133
|
+
display_name: string;
|
|
134
|
+
};
|
|
135
|
+
export type Api_Responsible_DTO = {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
display_name: string;
|
|
139
|
+
};
|
|
140
|
+
export type Api_VideoSource_DTO = {
|
|
141
|
+
id: string;
|
|
142
|
+
name: string;
|
|
143
|
+
url: string;
|
|
144
|
+
work_zone_by_task: {
|
|
145
|
+
id: string;
|
|
146
|
+
title: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export type Api_Task_DTO = {
|
|
150
|
+
id: string;
|
|
151
|
+
name: string;
|
|
152
|
+
plan_date: string;
|
|
153
|
+
deadline: string;
|
|
154
|
+
priority: number;
|
|
155
|
+
subtasks_count: number;
|
|
156
|
+
expired: boolean;
|
|
157
|
+
is_critical_path: boolean;
|
|
158
|
+
power_output_MWh: number;
|
|
159
|
+
cost_per_MWh: number;
|
|
160
|
+
isPause: boolean;
|
|
161
|
+
fact_start_date: null | string;
|
|
162
|
+
fact_end_date: null | string;
|
|
163
|
+
pause_sec: number;
|
|
164
|
+
work_sec: number;
|
|
165
|
+
has_quality_metrics: boolean;
|
|
166
|
+
responsible: Api_Responsible_DTO[];
|
|
167
|
+
assigned: Api_Assigned_DTO[];
|
|
168
|
+
status: Api_Status_DTO[];
|
|
169
|
+
teams: Api_Teams_DTO[];
|
|
170
|
+
video_source: Api_VideoSource_DTO;
|
|
171
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type Api_Search_User_Passes = {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
uuid: string;
|
|
5
|
+
};
|
|
6
|
+
export type Api_Search_User_Positions = {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
display_name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
export type Api_Search_User_Roles = {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
display_name: string;
|
|
16
|
+
};
|
|
17
|
+
export type Api_Search_User_Teams = {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
display_name: string;
|
|
21
|
+
roles: Api_Search_User_Roles[];
|
|
22
|
+
};
|
|
23
|
+
export type Api_Search_User_Photos = {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
path: string;
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
export type Api_Search_User = {
|
|
30
|
+
id: string;
|
|
31
|
+
full_name: string;
|
|
32
|
+
last_name: string;
|
|
33
|
+
first_name: string;
|
|
34
|
+
patronymic: string;
|
|
35
|
+
email: string;
|
|
36
|
+
phone: string;
|
|
37
|
+
divisions: string;
|
|
38
|
+
personnel_number: string;
|
|
39
|
+
passes: Api_Search_User_Passes[];
|
|
40
|
+
positions: Api_Search_User_Positions[];
|
|
41
|
+
teams: Api_Search_User_Teams[];
|
|
42
|
+
photos: Api_Search_User_Photos[];
|
|
43
|
+
};
|
package/package.json
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "shared-ritm",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"private": false,
|
|
5
|
-
"files": [
|
|
6
|
-
"dist",
|
|
7
|
-
"src"
|
|
8
|
-
],
|
|
9
|
-
"main": "dist/shared-ritm.umd.js",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"module": "./dist/shared-ritm.es.js",
|
|
12
|
-
"types": "./dist/types/index.d.ts",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"import": "./dist/shared-ritm.es.js",
|
|
16
|
-
"require": "./dist/shared-ritm.umd.js",
|
|
17
|
-
"default": "./dist/shared-ritm.es.js",
|
|
18
|
-
"types": "./dist/types/index.d.ts"
|
|
19
|
-
},
|
|
20
|
-
"./style": "./dist/index.css"
|
|
21
|
-
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"dev": "vite",
|
|
24
|
-
"build": "vite build && tsc --emitDeclarationOnly",
|
|
25
|
-
"typecheck": "vue-tsc --noEmit",
|
|
26
|
-
"lint": "eslint --fix",
|
|
27
|
-
"format": "prettier -w -u ."
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@quasar/extras": "^1.16.17",
|
|
31
|
-
"@vueuse/core": "^10.1.2",
|
|
32
|
-
"face-api.js": "^0.22.2",
|
|
33
|
-
"axios": "^1.7.7",
|
|
34
|
-
"vue": "^3.5.12",
|
|
35
|
-
"vue-router": "^4.0.3"
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"quasar": "^2.18.1"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@quasar/vite-plugin": "^1.9.0",
|
|
42
|
-
"@rollup/pluginutils": "^5.1.3",
|
|
43
|
-
"@types/node": "^22.7.9",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
|
45
|
-
"@typescript-eslint/parser": "^4.25.0",
|
|
46
|
-
"@vitejs/plugin-vue": "^5.1.4",
|
|
47
|
-
"@vue/compiler-sfc": "^3.0.5",
|
|
48
|
-
"@vue/eslint-config-prettier": "^6.0.0",
|
|
49
|
-
"@vue/eslint-config-typescript": "^7.0.0",
|
|
50
|
-
"eslint": "^7.27.0",
|
|
51
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
52
|
-
"eslint-plugin-vue": "^7.10.0",
|
|
53
|
-
"install": "^0.13.0",
|
|
54
|
-
"npm": "^11.4.0",
|
|
55
|
-
"prettier": "^2.3.0",
|
|
56
|
-
"quasar": "^2.18.1",
|
|
57
|
-
"rollup-plugin-visualizer": "^5.14.0",
|
|
58
|
-
"sass": "^1.80.4",
|
|
59
|
-
"typescript": "^5.6.3",
|
|
60
|
-
"vite": "^5.4.9",
|
|
61
|
-
"vite-plugin-css-modules": "^0.0.1",
|
|
62
|
-
"vue-tsc": "^2.1.6"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "shared-ritm",
|
|
3
|
+
"version": "1.2.76",
|
|
4
|
+
"private": false,
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"main": "dist/shared-ritm.umd.js",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"module": "./dist/shared-ritm.es.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/shared-ritm.es.js",
|
|
16
|
+
"require": "./dist/shared-ritm.umd.js",
|
|
17
|
+
"default": "./dist/shared-ritm.es.js",
|
|
18
|
+
"types": "./dist/types/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./style": "./dist/index.css"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "vite",
|
|
24
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
25
|
+
"typecheck": "vue-tsc --noEmit",
|
|
26
|
+
"lint": "eslint --fix",
|
|
27
|
+
"format": "prettier -w -u ."
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@quasar/extras": "^1.16.17",
|
|
31
|
+
"@vueuse/core": "^10.1.2",
|
|
32
|
+
"face-api.js": "^0.22.2",
|
|
33
|
+
"axios": "^1.7.7",
|
|
34
|
+
"vue": "^3.5.12",
|
|
35
|
+
"vue-router": "^4.0.3"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"quasar": "^2.18.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@quasar/vite-plugin": "^1.9.0",
|
|
42
|
+
"@rollup/pluginutils": "^5.1.3",
|
|
43
|
+
"@types/node": "^22.7.9",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
|
45
|
+
"@typescript-eslint/parser": "^4.25.0",
|
|
46
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
47
|
+
"@vue/compiler-sfc": "^3.0.5",
|
|
48
|
+
"@vue/eslint-config-prettier": "^6.0.0",
|
|
49
|
+
"@vue/eslint-config-typescript": "^7.0.0",
|
|
50
|
+
"eslint": "^7.27.0",
|
|
51
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
52
|
+
"eslint-plugin-vue": "^7.10.0",
|
|
53
|
+
"install": "^0.13.0",
|
|
54
|
+
"npm": "^11.4.0",
|
|
55
|
+
"prettier": "^2.3.0",
|
|
56
|
+
"quasar": "^2.18.1",
|
|
57
|
+
"rollup-plugin-visualizer": "^5.14.0",
|
|
58
|
+
"sass": "^1.80.4",
|
|
59
|
+
"typescript": "^5.6.3",
|
|
60
|
+
"vite": "^5.4.9",
|
|
61
|
+
"vite-plugin-css-modules": "^0.0.1",
|
|
62
|
+
"vue-tsc": "^2.1.6"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import * as faceapi from 'face-api.js'
|
|
2
|
-
|
|
3
|
-
class PhotoService {
|
|
4
|
-
// async getFaceSnapshot(inputImage: any, box: any) {
|
|
5
|
-
// const regionsToExtract = [new faceapi.Rect(box.x, box.y, box.width, box.height)]
|
|
6
|
-
// const faceImages = await faceapi.extractFaces(inputImage, regionsToExtract)
|
|
7
|
-
// if (faceImages.length) {
|
|
8
|
-
// const dataUrl = faceImages[0].toDataURL('image/jpeg')
|
|
9
|
-
// photo.value = dataUrl.replace(/^data:image\/\w+;base64,/, '')
|
|
10
|
-
// }
|
|
11
|
-
// }
|
|
12
|
-
|
|
13
|
-
// Метод настройки конфига для стрима
|
|
14
|
-
getVideoStreamConfig(width: number, height: number) {
|
|
15
|
-
return {
|
|
16
|
-
audio: false,
|
|
17
|
-
video: {
|
|
18
|
-
width: { min: width, ideal: width },
|
|
19
|
-
height: { min: height, ideal: height },
|
|
20
|
-
facingMode: 'environment', // или 'user' для фронтальной камеры
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Метод для настройки рамки, где должно помещаться лицо
|
|
26
|
-
getContourCoordinate(width: number, height: number) {
|
|
27
|
-
return {
|
|
28
|
-
x: width * 0.25,
|
|
29
|
-
y: height * 0.05,
|
|
30
|
-
width: width * 0.5,
|
|
31
|
-
height: height * 0.9,
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getBoxData(box: any) {
|
|
36
|
-
if (!box) return null
|
|
37
|
-
return {
|
|
38
|
-
x: box.x,
|
|
39
|
-
y: box.y,
|
|
40
|
-
width: box.width,
|
|
41
|
-
height: box.height,
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setStylesForCanvas(canvasContainer: any) {
|
|
46
|
-
canvasContainer.width = '100%'
|
|
47
|
-
canvasContainer.height = '100%'
|
|
48
|
-
canvasContainer.style.position = 'absolute'
|
|
49
|
-
canvasContainer.style.top = '0'
|
|
50
|
-
canvasContainer.style.left = '0'
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Метод для рассчёта того, что лицо полностью помещается в рамке
|
|
54
|
-
checkFaceInclusion(frame: any, face: any) {
|
|
55
|
-
if (!frame || !face) return false
|
|
56
|
-
|
|
57
|
-
if (face.width > frame.width || face.height > frame.height) {
|
|
58
|
-
return false
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const faceXmin = face.x
|
|
62
|
-
const faceXmax = face.x + face.width
|
|
63
|
-
const faceYmin = face.y
|
|
64
|
-
const faceYmax = face.y + face.height
|
|
65
|
-
|
|
66
|
-
const frameXmin = frame.x
|
|
67
|
-
const frameXmax = frame.x + frame.width
|
|
68
|
-
const frameYmin = frame.y
|
|
69
|
-
const frameYmax = frame.y + frame.height
|
|
70
|
-
|
|
71
|
-
return faceXmin >= frameXmin && faceXmax <= frameXmax && faceYmin >= frameYmin && faceYmax <= frameYmax
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async getFaceDetections(videoRef: any) {
|
|
75
|
-
if (!videoRef) return []
|
|
76
|
-
return faceapi
|
|
77
|
-
.detectAllFaces(videoRef, new faceapi.TinyFaceDetectorOptions())
|
|
78
|
-
.withFaceLandmarks()
|
|
79
|
-
.withFaceExpressions()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getCanvas(videoRef: any) {
|
|
83
|
-
return faceapi.createCanvasFromMedia(videoRef)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
getResizedAndDetection(canvas: any, detections: any, ctx: any, videoWidth: number, videoHeight: number) {
|
|
87
|
-
faceapi.matchDimensions(canvas, { width: videoWidth, height: videoHeight })
|
|
88
|
-
|
|
89
|
-
const resized = faceapi.resizeResults(detections, {
|
|
90
|
-
width: videoWidth,
|
|
91
|
-
height: videoHeight,
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
ctx.clearRect(0, 0, videoWidth, videoHeight)
|
|
95
|
-
|
|
96
|
-
faceapi.draw.drawDetections(canvas, resized)
|
|
97
|
-
faceapi.draw.drawFaceLandmarks(canvas, resized)
|
|
98
|
-
faceapi.draw.drawFaceExpressions(canvas, resized)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async getFaceSnapshot(inputImage: any, box: any) {
|
|
102
|
-
const regionsToExtract = [new faceapi.Rect(box.x, box.y, box.width, box.height)]
|
|
103
|
-
const faceImages = await faceapi.extractFaces(inputImage, regionsToExtract)
|
|
104
|
-
|
|
105
|
-
if (faceImages.length) {
|
|
106
|
-
const dataUrl = faceImages[0].toDataURL('image/jpeg')
|
|
107
|
-
return dataUrl.replace(/^data:image\/\w+;base64,/, '')
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return null
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async initModels() {
|
|
114
|
-
let date = new Date()
|
|
115
|
-
console.log(date)
|
|
116
|
-
try {
|
|
117
|
-
await Promise.all([
|
|
118
|
-
faceapi.nets.tinyFaceDetector.loadFromUri('/models'),
|
|
119
|
-
faceapi.nets.faceLandmark68Net.loadFromUri('/models'),
|
|
120
|
-
faceapi.nets.faceRecognitionNet.loadFromUri('/models'),
|
|
121
|
-
faceapi.nets.faceExpressionNet.loadFromUri('/models'),
|
|
122
|
-
//faceapi.nets.ssdMobilenetv1.loadFromUri('/models'),
|
|
123
|
-
])
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.error(error)
|
|
126
|
-
}
|
|
127
|
-
date = new Date()
|
|
128
|
-
console.log(date)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let api: PhotoService
|
|
133
|
-
|
|
134
|
-
export default function usePhotoService() {
|
|
135
|
-
if (!api) api = new PhotoService()
|
|
136
|
-
return api
|
|
137
|
-
}
|
|
1
|
+
import * as faceapi from 'face-api.js'
|
|
2
|
+
|
|
3
|
+
class PhotoService {
|
|
4
|
+
// async getFaceSnapshot(inputImage: any, box: any) {
|
|
5
|
+
// const regionsToExtract = [new faceapi.Rect(box.x, box.y, box.width, box.height)]
|
|
6
|
+
// const faceImages = await faceapi.extractFaces(inputImage, regionsToExtract)
|
|
7
|
+
// if (faceImages.length) {
|
|
8
|
+
// const dataUrl = faceImages[0].toDataURL('image/jpeg')
|
|
9
|
+
// photo.value = dataUrl.replace(/^data:image\/\w+;base64,/, '')
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
// Метод настройки конфига для стрима
|
|
14
|
+
getVideoStreamConfig(width: number, height: number) {
|
|
15
|
+
return {
|
|
16
|
+
audio: false,
|
|
17
|
+
video: {
|
|
18
|
+
width: { min: width, ideal: width },
|
|
19
|
+
height: { min: height, ideal: height },
|
|
20
|
+
facingMode: 'environment', // или 'user' для фронтальной камеры
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Метод для настройки рамки, где должно помещаться лицо
|
|
26
|
+
getContourCoordinate(width: number, height: number) {
|
|
27
|
+
return {
|
|
28
|
+
x: width * 0.25,
|
|
29
|
+
y: height * 0.05,
|
|
30
|
+
width: width * 0.5,
|
|
31
|
+
height: height * 0.9,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getBoxData(box: any) {
|
|
36
|
+
if (!box) return null
|
|
37
|
+
return {
|
|
38
|
+
x: box.x,
|
|
39
|
+
y: box.y,
|
|
40
|
+
width: box.width,
|
|
41
|
+
height: box.height,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setStylesForCanvas(canvasContainer: any) {
|
|
46
|
+
canvasContainer.width = '100%'
|
|
47
|
+
canvasContainer.height = '100%'
|
|
48
|
+
canvasContainer.style.position = 'absolute'
|
|
49
|
+
canvasContainer.style.top = '0'
|
|
50
|
+
canvasContainer.style.left = '0'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Метод для рассчёта того, что лицо полностью помещается в рамке
|
|
54
|
+
checkFaceInclusion(frame: any, face: any) {
|
|
55
|
+
if (!frame || !face) return false
|
|
56
|
+
|
|
57
|
+
if (face.width > frame.width || face.height > frame.height) {
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const faceXmin = face.x
|
|
62
|
+
const faceXmax = face.x + face.width
|
|
63
|
+
const faceYmin = face.y
|
|
64
|
+
const faceYmax = face.y + face.height
|
|
65
|
+
|
|
66
|
+
const frameXmin = frame.x
|
|
67
|
+
const frameXmax = frame.x + frame.width
|
|
68
|
+
const frameYmin = frame.y
|
|
69
|
+
const frameYmax = frame.y + frame.height
|
|
70
|
+
|
|
71
|
+
return faceXmin >= frameXmin && faceXmax <= frameXmax && faceYmin >= frameYmin && faceYmax <= frameYmax
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async getFaceDetections(videoRef: any) {
|
|
75
|
+
if (!videoRef) return []
|
|
76
|
+
return faceapi
|
|
77
|
+
.detectAllFaces(videoRef, new faceapi.TinyFaceDetectorOptions())
|
|
78
|
+
.withFaceLandmarks()
|
|
79
|
+
.withFaceExpressions()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getCanvas(videoRef: any) {
|
|
83
|
+
return faceapi.createCanvasFromMedia(videoRef)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getResizedAndDetection(canvas: any, detections: any, ctx: any, videoWidth: number, videoHeight: number) {
|
|
87
|
+
faceapi.matchDimensions(canvas, { width: videoWidth, height: videoHeight })
|
|
88
|
+
|
|
89
|
+
const resized = faceapi.resizeResults(detections, {
|
|
90
|
+
width: videoWidth,
|
|
91
|
+
height: videoHeight,
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
ctx.clearRect(0, 0, videoWidth, videoHeight)
|
|
95
|
+
|
|
96
|
+
faceapi.draw.drawDetections(canvas, resized)
|
|
97
|
+
faceapi.draw.drawFaceLandmarks(canvas, resized)
|
|
98
|
+
faceapi.draw.drawFaceExpressions(canvas, resized)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async getFaceSnapshot(inputImage: any, box: any) {
|
|
102
|
+
const regionsToExtract = [new faceapi.Rect(box.x, box.y, box.width, box.height)]
|
|
103
|
+
const faceImages = await faceapi.extractFaces(inputImage, regionsToExtract)
|
|
104
|
+
|
|
105
|
+
if (faceImages.length) {
|
|
106
|
+
const dataUrl = faceImages[0].toDataURL('image/jpeg')
|
|
107
|
+
return dataUrl.replace(/^data:image\/\w+;base64,/, '')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async initModels() {
|
|
114
|
+
let date = new Date()
|
|
115
|
+
console.log(date)
|
|
116
|
+
try {
|
|
117
|
+
await Promise.all([
|
|
118
|
+
faceapi.nets.tinyFaceDetector.loadFromUri('/models'),
|
|
119
|
+
faceapi.nets.faceLandmark68Net.loadFromUri('/models'),
|
|
120
|
+
faceapi.nets.faceRecognitionNet.loadFromUri('/models'),
|
|
121
|
+
faceapi.nets.faceExpressionNet.loadFromUri('/models'),
|
|
122
|
+
//faceapi.nets.ssdMobilenetv1.loadFromUri('/models'),
|
|
123
|
+
])
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error(error)
|
|
126
|
+
}
|
|
127
|
+
date = new Date()
|
|
128
|
+
console.log(date)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let api: PhotoService
|
|
133
|
+
|
|
134
|
+
export default function usePhotoService() {
|
|
135
|
+
if (!api) api = new PhotoService()
|
|
136
|
+
return api
|
|
137
|
+
}
|