Skip to content

Commit 25749c7

Browse files
committed
chore: 升级到vue3版本
1 parent 8bd3191 commit 25749c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3717
-14728
lines changed

.gitignore

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
.DS_Store
2-
node_modules
3-
/dist
4-
5-
# local env files
6-
.env.local
7-
.env.*.local
8-
9-
# Log files
1+
# Logs
2+
logs
3+
*.log
104
npm-debug.log*
115
yarn-debug.log*
126
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
1314

1415
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
1518
.idea
16-
.vscode
19+
.DS_Store
1720
*.suo
1821
*.ntvs*
1922
*.njsproj

LICENSE

Lines changed: 21 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,21 @@
1-
木兰宽松许可证, 第1版
2-
3-
木兰宽松许可证, 第1版
4-
2019年8月 http://license.coscl.org.cn/MulanPSL
5-
6-
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第1版(“本许可证”)的如下条款的约束:
7-
8-
0. 定义
9-
10-
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
11-
12-
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
13-
14-
“法人实体”是指提交贡献的机构及其“关联实体”。
15-
16-
“关联实体”是指,对“本许可证”下的一方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
17-
18-
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
19-
20-
1. 授予版权许可
21-
22-
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
23-
24-
2. 授予专利许可
25-
26-
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括仅因您或他人修改“贡献”或其他结合而将必然会侵犯到的专利权利要求。如您或您的“关联实体”直接或间接地(包括通过代理、专利被许可人或受让人),就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
27-
28-
3. 无商标许可
29-
30-
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
31-
32-
4. 分发限制
33-
34-
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
35-
36-
5. 免责声明与责任限制
37-
38-
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
39-
40-
条款结束。
41-
42-
如何将木兰宽松许可证,第1版,应用到您的软件
43-
44-
如果您希望将木兰宽松许可证,第1版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
45-
46-
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
47-
48-
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
49-
50-
3, 请将如下声明文本放入每个源文件的头部注释中。
51-
52-
Copyright (c) [2019] [name of copyright holder]
53-
[Software Name] is licensed under the Mulan PSL v1.
54-
You can use this software according to the terms and conditions of the Mulan PSL v1.
55-
You may obtain a copy of Mulan PSL v1 at:
56-
http://license.coscl.org.cn/MulanPSL
57-
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
58-
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
59-
PURPOSE.
60-
See the Mulan PSL v1 for more details.
61-
62-
63-
Mulan Permissive Software License,Version 1
64-
65-
Mulan Permissive Software License,Version 1 (Mulan PSL v1)
66-
August 2019 http://license.coscl.org.cn/MulanPSL
67-
68-
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v1 (this License) with following terms and conditions:
69-
70-
0. Definition
71-
72-
Software means the program and related documents which are comprised of those Contribution and licensed under this License.
73-
74-
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
75-
76-
Legal Entity means the entity making a Contribution and all its Affiliates.
77-
78-
Affiliates means entities that control, or are controlled by, or are under common control with a party to this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
79-
80-
Contribution means the copyrightable work licensed by a particular Contributor under this License.
81-
82-
1. Grant of Copyright License
83-
84-
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
85-
86-
2. Grant of Patent License
87-
88-
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed, excluding of any patent claims solely be infringed by your or others’ modification or other combinations. If you or your Affiliates directly or indirectly (including through an agent, patent licensee or assignee), institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
89-
90-
3. No Trademark License
91-
92-
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
93-
94-
4. Distribution Restriction
95-
96-
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
97-
98-
5. Disclaimer of Warranty and Limitation of Liability
99-
100-
The Software and Contribution in it are provided without warranties of any kind, either express or implied. In no event shall any Contributor or copyright holder be liable to you for any damages, including, but not limited to any direct, or indirect, special or consequential damages arising from your use or inability to use the Software or the Contribution in it, no matter how it’s caused or based on which legal theory, even if advised of the possibility of such damages.
101-
102-
End of the Terms and Conditions
103-
104-
How to apply the Mulan Permissive Software License,Version 1 (Mulan PSL v1) to your software
105-
106-
To apply the Mulan PSL v1 to your work, for easy identification by recipients, you are suggested to complete following three steps:
107-
108-
i. Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
109-
ii. Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
110-
iii. Attach the statement to the appropriate annotated syntax at the beginning of each source file.
111-
112-
Copyright (c) [2019] [name of copyright holder]
113-
[Software Name] is licensed under the Mulan PSL v1.
114-
You can use this software according to the terms and conditions of the Mulan PSL v1.
115-
You may obtain a copy of Mulan PSL v1 at:
116-
http://license.coscl.org.cn/MulanPSL
117-
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
118-
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
119-
PURPOSE.
120-
121-
See the Mulan PSL v1 for more details.
1+
MIT License
2+
3+
Copyright (c) 2021 TsMask
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 64 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,26 @@
22

33
使用 `Vue` 框架搭建演示,`H5``Web``NodeJS` 实现人脸检测识别,基于 `TensorFlowJS` 实现的 `face-api.js` 人脸识别库。
44

5-
起初在 2018 年时,有个项目用人脸检测,当时我在百度寻找了一下关于在浏览器网页 `JavaScript` 实现人脸识别的方法很少,好多都是用 `百度AI` 人脸识别接口来实现的。当时 `Python` 人工智能方面最为热门,很多是做人脸识别和数据分析处理,在 `GitHub` 上找到人脸识别、机器视觉都是基于 `OpenCV` 来处理图片,当时发现有个 `NodeJS` 图像识别处理叫做 `opencv4nodejs` 的识别库,在作者的仓库内还发现 `face-api.js` 这个人脸识别库。采用 `TensorFlowJS` 机器学习库进行模型训练,提升识别功能精确度,感觉不错而且功能也强
5+
模型文件放在 `public\models` 目录下,部署时请确保网络路径能访问到模型文件
66

7-
安装依赖库,模型文件放在 `public\models` 目录下,npm 主要安装以下:
7+
npm 主要安装以下:
88

99
```shell
1010
npm i --save face-api.js
11-
npm i --save webrtc-adapter
1211
```
1312

1413
- [face-api 使用文档](https://justadudewhohacks.github.io/face-api.js/docs/globals.html)
1514
- [我仓库 browser 示例 0.13.8 含 dist/文档/模型/示例](https://github.com/TsMask/face-api-demo)
1615
- [GitHub 作者识别库源码](https://github.com/justadudewhohacks/face-api.js)
1716
- [GitHub 作者在线示例](https://justadudewhohacks.github.io/face-api.js)
1817

19-
## 项目说明
20-
21-
示例参考 `face-api.js` 作者提供示例源码 `examples-browser`
22-
23-
内含功能:
24-
25-
1. 脸标志检测
26-
2. 人脸表情识别
27-
3. 年龄和性别识别
28-
4. 人脸提取
29-
5. 人脸识别
30-
6. 人脸识别多图处理
31-
7. BBT 图片相似度
32-
8. BBT 图片相似度多查找
33-
9. BBT 人脸识别
34-
10. Video 人脸跟踪
35-
11. Video 人脸识别
36-
12. WebRTC 人脸跟踪
37-
13. WebRTC 人脸识别
38-
14. WebRTC 媒体流基础
39-
40-
编译执行环境:
41-
42-
- NodeJS:`v12.13.0`
43-
- Vue 脚手架:`@vue/cli@4.3.1`
44-
- Vue:`^2.6.11`
45-
- face-api.js:`^0.22.2`
46-
- webrtc-adapter:`^7.5.1`
47-
48-
## 项目结构
49-
50-
```text
51-
face-api-demo-vue
52-
┌─public 应用引用静态资源的目录
53-
├─src
54-
│ ├─components 复用组件目录
55-
│ ├─router 页面路由配置文件目录
56-
│ ├─utils 常用函数工具文件目录
57-
│ ├─views 页面视图文件目录
58-
│ ├─App.vue 配置App全局应用页面
59-
│ └─main.js Vue初始化入口文件
60-
├─babel.config.js Babel格式规范化配置
61-
├─package-lock.json 依赖版本校验信息
62-
├─package.json 项目依赖包、编译配置
63-
└─README.md 项目说明
64-
```
65-
6618
## 其他
6719

68-
**使用前引入模型**
20+
### 使用前引入模型
6921

70-
```
22+
[关于mtcnn模型弃用](https://github.com/justadudewhohacks/face-api.js/issues/511)
23+
24+
```js
7125
console.log(faceapi.nets);
7226
// ageGenderNet
7327
// faceExpressionNet
@@ -84,7 +38,7 @@ console.log(faceapi.nets);
8438
// await faceapi.nets.ssdMobilenetv1.loadFromDisk("../../public/models");
8539
```
8640

87-
**侦测人脸**
41+
### 侦测人脸
8842

8943
- detectAllFaces :检测图像中的所有脸部
9044
- detectSingleFace :检测图像中具有最高置信度得分的脸部
@@ -93,7 +47,7 @@ console.log(faceapi.nets);
9347

9448
您可以通过传递相应的 options 对象来指定面部检测器:
9549

96-
```
50+
```js
9751
const detections1 = await faceapi.detectAllFaces(输入, 使用的模型参数)
9852
const detections2 = await faceapi.detectSingleFace(输入, 使用的模型参数)
9953
```
@@ -102,9 +56,9 @@ const detections2 = await faceapi.detectSingleFace(输入, 使用的模型参数
10256

10357
使用的模型参数 :配置识别度和修改人脸框,请看 `识别库说明` 或者 `查阅文档`
10458

105-
**识别库工具**
59+
### 识别库工具
10660

107-
```
61+
```js
10862
// 请求json格式文件数据
10963
const json = await faceapi.fetchJson("http://www.example.com/file/example.json");
11064

@@ -115,32 +69,74 @@ const imgEl = await faceapi.bufferToImage(imgFile);
11569
const canvas = faceapi.createCanvasFromMedia(HTMLImageElement | HTMLVideoElement)
11670
```
11771

118-
---
72+
----
11973

120-
## Project setup / 项目依赖安装初始化
74+
## 当前项目说明
12175

76+
示例参考 `face-api.js` 作者提供示例源码 `examples-browser`
77+
78+
内含功能:
79+
80+
1. [脸标志检测](src\views\FaceLandmarkDetection.vue)
81+
2. [人脸表情识别](src\views\FaceExpressionRecognition.vue)
82+
3. [年龄和性别识别](src\views\AgeAndGenderRecognition.vue)
83+
4. [人脸提取](src\views\FaceExtraction.vue)
84+
5. [人脸识别](src\views\FaceRecognition.vue)
85+
6. [人脸识别多图处理](src\views\FaceRecognitionMore.vue)
86+
7. [BBT 人脸识别](src\views\BBTFaceRecognition.vue)
87+
8. [BBT 图片相似度](src\views\BBTFaceSimilarity.vue)
88+
9. [BBT 图片相似度多查找](src\views\BBTFaceSimilarityMore.vue)
89+
10. [Video 人脸跟踪](src\views\VideoFaceDetector.vue)
90+
11. [Video 人脸识别](src\views\VideoFaceRecognition.vue)
91+
12. [WebRTC 人脸跟踪](src\views\WebRTCFaceDetector.vue)
92+
13. [WebRTC 人脸识别](src\views\WebRTCFaceRecognition.vue)
93+
14. [WebRTC 媒体流基础](src\views\WebRTCMediaStream.vue)
94+
95+
编译执行环境:
96+
97+
- NodeJS:`nodejs@18.16.0`
98+
- Vite 脚手架:`vite@5.2.3`
99+
- Vue:`vue@3.4.20`
100+
- face-api:`face-api.js@0.22.2`
101+
102+
## 项目结构
103+
104+
```text
105+
face-api-demo-vue
106+
┌─public 应用引用静态资源的目录
107+
├─src
108+
│ ├─components 复用组件目录
109+
│ ├─router 页面路由配置文件目录
110+
│ ├─utils 常用函数工具文件目录
111+
│ ├─views 页面视图文件目录
112+
│ ├─App.vue 配置App全局应用页面
113+
│ └─main.js Vue初始化入口文件
114+
├─babel.config.js Babel格式规范化配置
115+
├─package-lock.json 依赖版本校验信息
116+
├─package.json 项目依赖包、编译配置
117+
└─README.md 项目说明
122118
```
119+
120+
## Project setup / 项目依赖安装初始化
121+
122+
```bash
123123
npm install
124+
# 使用阿里源可以加速下载依赖库
125+
npm install --registry https://registry.npmmirror.com
124126
```
125127

126128
### Compiles and hot-reloads for development / 项目编译热更新用于开发调试
127129

128-
```
129-
npm run serve
130+
```bash
131+
npm run dev
130132
```
131133

132134
### Compiles and minifies for production / 项目编译打包用于部署
133135

134-
```
136+
```bash
135137
npm run build
136138
```
137139

138-
### Lints and fixes files / 代码检查和文件规范格式化
139-
140-
```
141-
npm run lint
142-
```
143-
144140
### Customize configuration / 更多脚手架配置
145141

146-
See [Configuration Reference](https://cli.vuejs.org/config/).
142+
See [Configuration Reference](https://vitejs.dev/config/).

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="zh_CN">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>face-api-demo-vue</title>
9+
</head>
10+
<body>
11+
<div id="app"></div>
12+
<script type="module" src="/src/main.js"></script>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)