Skip to content

Commit

Permalink
DY11
Browse files Browse the repository at this point in the history
  • Loading branch information
enpeizhao committed Dec 26, 2021
1 parent e234106 commit 5502134
Show file tree
Hide file tree
Showing 15 changed files with 37,557 additions and 8 deletions.
Binary file modified .DS_Store
Binary file not shown.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

### 二、项目列表

| 名称 | 截图 | 难度 | 代码 |
| -------------------------- | ------------------------------------------------------------ | ------------------------ | ------------------------------------------------------------ |
| 10.AI虚拟鼠标 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/imgIMG_6083.PNG?x-oss-process=style/wp" style="width:200px;" /> | :star: | [codes/10.virtual_mouse](https://github.com/enpeizhao/CVprojects/tree/main/codes/10.virtual_mouse) |
| 9.AI 虚拟点读机 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211211154451.png?x-oss-process=style/wp" style="width:200px;" /> | :star::star::star: | [codes/9.virtual reader](https://github.com/enpeizhao/CVprojects/tree/main/codes/9.virtual%20reader) |
| 8. 火影结印识别 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211201102837.png?x-oss-process=style/wp" style="width:200px;" /> | :star::star::star::star: | [codes/8.结印识别](https://github.com/enpeizhao/CVprojects/tree/main/codes/8.%E7%BB%93%E5%8D%B0%E8%AF%86%E5%88%AB) |
| 7.虚拟拖放 Python + opencv | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211120135236.png?x-oss-process=style/wp" style="width:200px;" /> | :star::star: | [codes/7.virtual_drag_drop.py](https://github.com/enpeizhao/CVprojects/blob/main/codes/7.virtual_drag_drop) |
| 6.Python手势控制电脑音量 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211120135209.png?x-oss-process=style/wp" style="width:200px;" /> | :star: | [codes/6.hand_control_volume.py](https://github.com/enpeizhao/CVprojects/blob/main/codes/6.hand_control_volume) |
| 5.手势暂停、播放电视 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/imgIMG_5885.jpg?x-oss-process=style/wp" style="width:200px" /> | :star::star::star: | [codes/5.hand_pause_atv/handRemote.py](https://github.com/enpeizhao/CVprojects/blob/main/codes/5.hand_pause_atv/ ) |
| 名称 | 截图 | 难度 | 代码 |
| -------------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| 11.AI分析看电视行为 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/imgIMG_6178.PNG?x-oss-process=style/wp" style="width:200px;" /> | ⭐️⭐️⭐️ | [codes/11.watch_tv](https://github.com/enpeizhao/CVprojects/tree/main/codes/11.watch_tv) |
| 10.AI虚拟鼠标 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/imgIMG_6083.PNG?x-oss-process=style/wp" style="width:200px;" /> | ⭐️ | [codes/10.virtual_mouse](https://github.com/enpeizhao/CVprojects/tree/main/codes/10.virtual_mouse) |
| 9.AI 虚拟点读机 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211211154451.png?x-oss-process=style/wp" style="width:200px;" /> | ⭐️⭐️⭐️ | [codes/9.virtual reader](https://github.com/enpeizhao/CVprojects/tree/main/codes/9.virtual%20reader) |
| 8. 火影结印识别 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211201102837.png?x-oss-process=style/wp" style="width:200px;" /> | ⭐️⭐️⭐️⭐️ | [codes/8.结印识别](https://github.com/enpeizhao/CVprojects/tree/main/codes/8.%E7%BB%93%E5%8D%B0%E8%AF%86%E5%88%AB) |
| 7.虚拟拖放 Python + opencv | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211120135236.png?x-oss-process=style/wp" style="width:200px;" /> | ⭐️⭐️ | [codes/7.virtual_drag_drop.py](https://github.com/enpeizhao/CVprojects/blob/main/codes/7.virtual_drag_drop) |
| 6.Python手势控制电脑音量 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211120135209.png?x-oss-process=style/wp" style="width:200px;" /> | ⭐️ | [codes/6.hand_control_volume.py](https://github.com/enpeizhao/CVprojects/blob/main/codes/6.hand_control_volume) |
| 5.手势暂停、播放电视 | <img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/imgIMG_5885.jpg?x-oss-process=style/wp" style="width:200px" /> | ⭐️⭐️⭐️ | [codes/5.hand_pause_atv/handRemote.py](https://github.com/enpeizhao/CVprojects/blob/main/codes/5.hand_pause_atv/ ) |


### 三、交流微信:
Expand Down
Binary file modified codes/.DS_Store
Binary file not shown.
Binary file added codes/11.watch_tv/.DS_Store
Binary file not shown.
77 changes: 77 additions & 0 deletions codes/11.watch_tv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# AI分析看电视行为

<img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/imgIMG_6178.PNG?x-oss-process=style/wp" style="width:300px;" />

#### 一、功能:

* 人脸识别:检查谁在看
* 头部姿态估计:检查是否在看
* 距离估计:检查是否离电视太近

#### 二、硬件:

* Windows10或11(无需GPU)或MacOS 都测试可行
* 普通RBG USB摄像头

#### 三、软件:

* python 3.7.10

`pip`安装一下依赖包

```
dlib
opencv-contrib-python(可能需要先卸载opencv-python:pip uninstall opencv-python)
```

#### 四、使用方法:

`python demo.py --命令=参数`

```
-h, --help 显示帮助
--mode MODE 运行模式:collect,train,distance,run对应:采集、训练、评估距离、主程序
--label_id LABEL_ID 采集照片标签id.
--img_count IMG_COUNT
采集照片数量
--img_interval IMG_INTERVAL
采集照片间隔时间
--display DISPLAY 显示模式,取值1-5
--w W 画面宽度
--h H 画面高度
```

##### 4.1 自定义人脸识别照片

项目使用最简单的opencv内置的人脸识别算法(精度有限),需要识别自己的人脸请按以下步骤:

1. **采集照片:**`python demo.py --mode='collect' --label_id={人脸ID} --img_count={该ID采集照片数量,一般1-3张即可} --img_interval={照片采集间隔(秒)}; `
2. **修改label:**修改`./face_mode/label.txt`文件,每行代表一个人,如`1,恩培`表示`label_id=1`的人脸叫恩培;
3. **训练模型:**`python demo.py --mode='train'`训练人脸识别模型,模型是`./face_model/model.yml`

##### 4.2 设置距离参数

项目使用相似三角形原理估算(`f`为相机焦距):

<img src="https://enpei-md.oss-cn-hangzhou.aliyuncs.com/img20211226120754.png?x-oss-process=style/wp" style="width:600px;" />



公式中的`a`取值为人眼角像素距离,参数在`demo.py`第27行`self.eyeBaseDistance = 65`,如果觉得距离不准,请修正这个参数,运行`python demo.py --mode='distance'`,保持相机和人眼睛高度一样,距离相机1.5m处。

##### 4.3 主程序

`python demo.py --mode='run' --w={宽度} --{高度} --display={显示模式}``display`取值对应:

* 1:人脸框
* 2:68个人脸关键点
* 3:人脸梯形框框
* 4:人脸方向指针
* 5:人脸三维坐标系







Binary file added codes/11.watch_tv/assets/.DS_Store
Binary file not shown.
204 changes: 204 additions & 0 deletions codes/11.watch_tv/assets/model.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
-73.393523
-72.775014
-70.533638
-66.850058
-59.790187
-48.368973
-34.121101
-17.875411
0.098749
17.477031
32.648966
46.372358
57.343480
64.388482
68.212038
70.486405
71.375822
-61.119406
-51.287588
-37.804800
-24.022754
-11.635713
12.056636
25.106256
38.338588
51.191007
60.053851
0.653940
0.804809
0.992204
1.226783
-14.772472
-7.180239
0.555920
8.272499
15.214351
-46.047290
-37.674688
-27.883856
-19.648268
-28.272965
-38.082418
19.265868
27.894191
37.437529
45.170805
38.196454
28.764989
-28.916267
-17.533194
-6.684590
0.381001
8.375443
18.876618
28.794412
19.057574
8.956375
0.381549
-7.428895
-18.160634
-24.377490
-6.897633
0.340663
8.444722
24.474473
8.449166
0.205322
-7.198266
-29.801432
-10.949766
7.929818
26.074280
42.564390
56.481080
67.246992
75.056892
77.061286
74.758448
66.929021
56.311389
42.419126
25.455880
6.990805
-11.666193
-30.365191
-49.361602
-58.769795
-61.996155
-61.033399
-56.686759
-57.391033
-61.902186
-62.777713
-59.302347
-50.190255
-42.193790
-30.993721
-19.944596
-8.414541
2.598255
4.751589
6.562900
4.661005
2.643046
-37.471411
-42.730510
-42.711517
-36.754742
-35.134493
-34.919043
-37.032306
-43.342445
-43.110822
-38.086515
-35.532024
-35.484289
28.612716
22.172187
19.029051
20.721118
19.035460
22.394109
28.079924
36.298248
39.634575
40.395647
39.836405
36.677899
28.677771
25.475976
26.014269
25.326198
28.323008
30.596216
31.408738
30.844876
47.667532
45.909403
44.842580
43.141114
38.635298
30.750622
18.456453
3.609035
-0.881698
5.181201
19.176563
30.770570
37.628629
40.886309
42.281449
44.142567
47.140426
14.254422
7.268147
0.442051
-6.606501
-11.967398
-12.051204
-7.315098
-1.022953
5.349435
11.615746
-13.380835
-21.150853
-29.284036
-36.948060
-20.132003
-23.536684
-25.944448
-23.695741
-20.858157
7.037989
3.021217
1.353629
-0.111088
-0.147273
1.476612
-0.665746
0.247660
1.696435
4.894163
0.282961
-1.172675
-2.240310
-15.934335
-22.611355
-23.748437
-22.721995
-15.610679
-3.217393
-14.987997
-22.554245
-23.591626
-22.406106
-15.121907
-4.785684
-20.893742
-22.220479
-21.025520
-5.712776
-20.671489
-21.903670
-20.328022
Binary file not shown.
Loading

0 comments on commit 5502134

Please sign in to comment.