├── 0_index.php
├── 1_upload_file.php
├── 1_upload_file_ed.php
├── 2_getface.php
├── 2_getface.py
├── 2_getface_ed.php
├── 3_facepoint.php
├── 3_facepoint.py
├── 3_facepoint_ed.php
├── 4_onchain.php
├── FaceDetect.exe
├── FacePointDetect.exe
├── Input
├── Connect_20_40_0.6.txt
├── Connect_20_40_1.0.txt
├── Connect_40_60_0.8.txt
├── Net_EN0.txt
├── Net_F0.txt
├── Net_LE1.txt
├── Net_LM1.txt
├── Net_N1.txt
├── Net_NM0.txt
├── Net_RE1.txt
├── Net_RM1.txt
├── Patch_EN0.txt
├── Patch_F0.txt
├── Patch_LE1_13.txt
├── Patch_LE1_15.txt
├── Patch_LE2_10.txt
├── Patch_LE2_9.txt
├── Patch_LM1_13.txt
├── Patch_LM1_15.txt
├── Patch_LM2_10.txt
├── Patch_LM2_9.txt
├── Patch_N1_13.txt
├── Patch_N1_15.txt
├── Patch_N2_10.txt
├── Patch_N2_9.txt
├── Patch_NM0.txt
├── Patch_RE1_13.txt
├── Patch_RE1_15.txt
├── Patch_RE2_10.txt
├── Patch_RE2_9.txt
├── Patch_RM1_13.txt
├── Patch_RM1_15.txt
├── Patch_RM2_10.txt
├── Patch_RM2_9.txt
├── Weight_EN0.bin
├── Weight_F0.bin
├── Weight_LE1_13.bin
├── Weight_LE1_15.bin
├── Weight_LE2_10.bin
├── Weight_LE2_9.bin
├── Weight_LM1_13.bin
├── Weight_LM1_15.bin
├── Weight_LM2_10.bin
├── Weight_LM2_9.bin
├── Weight_N1_13.bin
├── Weight_N1_15.bin
├── Weight_N2_10.bin
├── Weight_N2_9.bin
├── Weight_NM0.bin
├── Weight_RE1_13.bin
├── Weight_RE1_15.bin
├── Weight_RE2_10.bin
├── Weight_RE2_9.bin
├── Weight_RM1_13.bin
├── Weight_RM1_15.bin
├── Weight_RM2_10.bin
└── Weight_RM2_9.bin
├── Output
├── imagebbox.list
├── imagebbox__recover.list
├── imagebbox_detect.list
├── imagebbox_detect_recover_replace.list
├── imagebbox_detect_replace.list
├── imagebbox_miss.list
├── imagebbox_recover_detect.list
├── imagebbox_recover_miss.list
├── imagelist.list
├── imagelist_point.list
├── imagelist_recover.list
├── readme.md
└── result.bin
├── README.md
├── aligment.py
├── blank.htm
├── cleanBoxFile.py
├── data
├── detector_lfp.dat
└── svmpostfilter_lfp.dat
├── demo0.JPG
├── demo1.JPG
├── facecrop.py
├── facepoint.py
├── img
├── bg.jpg
└── logo.png
├── imresize.py
├── index.css
├── index.htm
├── lib
├── bootstrap-4.0.0-dist
│ ├── css
│ │ ├── bootstrap-grid.css
│ │ ├── bootstrap-grid.css.map
│ │ ├── bootstrap-grid.min.css
│ │ ├── bootstrap-grid.min.css.map
│ │ ├── bootstrap-reboot.css
│ │ ├── bootstrap-reboot.css.map
│ │ ├── bootstrap-reboot.min.css
│ │ ├── bootstrap-reboot.min.css.map
│ │ ├── bootstrap.css
│ │ ├── bootstrap.css.map
│ │ ├── bootstrap.min.css
│ │ └── bootstrap.min.css.map
│ └── js
│ │ ├── bootstrap.bundle.js
│ │ ├── bootstrap.bundle.js.map
│ │ ├── bootstrap.bundle.min.js
│ │ ├── bootstrap.bundle.min.js.map
│ │ ├── bootstrap.js
│ │ ├── bootstrap.js.map
│ │ ├── bootstrap.min.js
│ │ └── bootstrap.min.js.map
├── jquery-3.3.1.min.js
├── nebPay.js
└── nebulas.js
├── main.py
├── makeImageFileList.py
├── makeimagelist.py
├── opencv_core231.dll
├── opencv_highgui231.dll
├── opencv_imgproc231.dll
├── retain_max_face.py
├── skimagetest.py
├── smartContract
└── nasface.js
├── tbb.dll
├── test.py
└── textutil.py
/0_index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 人脸识别on区块链NasFace
14 |
15 |
16 | Step 1 →
17 | 请上传一张包含人脸的图片
18 |
19 | ◆单张不超过2M
20 |
21 | ◆支持jpg、png格式文件
22 |
29 |
30 |
31 |
32 |
33 |
34 | 作品介绍
35 |
36 | ◆本作品提供一套完整的【人脸识别】解决方案,并使用【区块链】存储和查询人脸特征数据,可广泛应用于各种场景,如【人脸锁】。
37 |
38 | ◆本作品区块链方案采用【星云链Nebulas】,请在开始使用前安装好WebExtensionWallet并创建账户后刷新本页,再开始操作。否则一系列的前期操作结果最终将无法与区块链交互,以至体验不到本作品运用区块链的核心意义。
39 |
40 | ◆【开源代码&演示文档】【区块链合约】
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/1_upload_file.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
9 |
10 | 不成功,请返回!";
37 | exit();
38 | }
39 |
40 | //echo $file["size"];
41 | if(2000000 < $file["size"])
42 | //检查文件大小
43 | {
44 | echo "错误_单张图片不要超过2M!不成功,请返回!";
45 | exit();
46 | }
47 |
48 | //判断是否是通过HTTP POST上传的
49 | if(!is_uploaded_file($file['tmp_name'])){
50 | //如果不是通过HTTP POST上传的
51 | echo "错误_图片存在异常!不成功,请返回!";
52 | exit();
53 | }
54 |
55 | // $upload_path = "D:/phpStudy/WWW/2017bqp/uploadpic/"; //上传文件的存放路径
56 |
57 | $thetime = time();
58 | $upload_path = "faces/uploadpic_".$thetime.""; //上传文件的存放路径 相对地址
59 | //开始移动文件到相应的文件夹
60 | mkdir($upload_path);
61 | $file['name_time'] = $upload_path."/face.".$type;
62 |
63 | if(move_uploaded_file($file['tmp_name'],$file['name_time'])){
64 | //echo "Successfully!";
65 | //echo "uploadpic/".$file['name_time'];
66 |
67 | //RETURN "uploadpic/".$file['name_time'];
68 | RETURN $file['name_time'];
69 |
70 | }else{
71 | echo "错误_图片存在异常情况!不成功,请返回!";
72 | exit();
73 | }
74 |
75 | }
76 |
77 |
78 | $picurl = fileupload($picfile);
79 |
80 |
81 | if($picurl!=NULL)
82 | {
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | echo "
91 |
95 | ";
96 |
97 |
98 | //echo "
";
99 | //echo "下一步 人脸提取并对齐
";
100 |
101 | }
102 |
103 | ?>
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/1_upload_file_ed.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
9 |
10 | ";
26 | echo "
";
27 | echo "
Step 2 →
";
28 |
29 | echo "
";
30 | echo "下一步 人脸提取并对齐 →
";
31 | echo "点击后请耐心等待,计算过程大约一分钟,期间请不要再次点击,直到右边出现结果
";
32 |
33 |
34 | ?>
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/2_getface.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
9 |
10 |
11 |
46 |
47 |
48 |
49 | ";
50 |
51 |
52 |
53 |
54 | ?>
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/2_getface.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Created on Wed Apr 22 21:20:45 2015
4 |
5 | @author: Chenriwei
6 |
7 | @function:
8 | 主要实现人脸检测、关键点检测、人脸对齐、归一化等操作。
9 | 将各个步骤衔接起来,实现一键操作。
10 |
11 | @attention:
12 | 1,只适合在windows下使用;
13 | 2,人脸检测器和关键点检测器利用了香港中文大学提供的二进制文件,版权归他们所有;
14 | 3,可以用更好的人脸检测器和关键点检测器来替换掉默认的检测器。
15 | """
16 | import makeimagelist
17 | import os
18 | import aligment
19 | import facecrop
20 | import textutil
21 |
22 | import sys
23 |
24 | def test(ImagePath,savePathDetect,savePathAligned,savePathCroped,fileformat=['png','jpg'],tag_recover=False,savesize=[128,128]):
25 | '''
26 | 必须提供的参数:
27 | 1,@ImagePath:待检测和对齐的图像路径
28 | 2,@savePathDetect:保存检测到的人脸的文件夹路径
29 | 3,@savePathAligned:保存对其后的人脸文件夹路径
30 | 可选的参数(有默认值):
31 | 4,@fileformat:图像的格式列表,默认为png和jpg格式
32 | 5,@tag_recover: 是否先裁剪处人脸图像之后再做归一化,默认为False
33 | 6, @savesize: 检测后保留的人脸图像的大小,当tag_recover=True 的时候,才会生效,默认大小为64*64
34 |
35 | '''
36 |
37 | if not os.path.exists(savePathDetect):
38 | os.makedirs(savePathDetect)
39 | if not os.path.exists(savePathAligned):
40 | os.makedirs(savePathAligned)
41 | if not os.path.exists(savePathCroped):
42 | os.makedirs(savePathCroped)
43 |
44 |
45 | print ('Begin making filelist. step (1/6) ')
46 | #创建imagelist.list 文件,用来保存文件图像文件列表
47 | imagelist = './Output/imagelist.list'
48 | fid=open(imagelist,'w')
49 | makeimagelist.makeImageFileList(ImagePath,fid,fileformat)
50 | fid.close()
51 | #统计有多少个图像文件
52 | count=textutil.count_text_line(imagelist)
53 | textutil.insertLine(imagelist,1,str(count))
54 |
55 | print ('Done make file list. step(1/6)')
56 |
57 | #人脸检测,生成imageBbox.list 文件,
58 | print ('Begin Face Detection task. step(2/6)')
59 | bboxlist='./Output/imagebbox.list'
60 | os.system('FaceDetect.exe data '+imagelist+' '+bboxlist)
61 | print ('Done Face Detection task.step(2/6)')
62 |
63 | #清除检测不到的图像,或者检测到多个的文件,以便于后面的人脸关键点检测。
64 | print ('Begin Box file Clean and Replace. step(3/6)')
65 | detectlist='./Output/imagebbox_detect.list'
66 | misslist='./Output/imagebbox_miss.list'
67 | textutil.cleanbox(fileinput=bboxlist,detectlistfile=detectlist,misslistfile=misslist)
68 | replacelist='./Output/imagebbox_detect_replace.list'
69 | textutil.replace_file(detectlist,replacelist,ImagePath)
70 | print ('Done Box file Clean and Replace. step(3/6)' )
71 |
72 | if tag_recover==True:
73 | #人脸先裁剪
74 | # 保留检测到的人脸图像,可选,
75 | print ('Begin Save Detected Face Image. step(4/4) optional')
76 | facecrop.face_cropout(ImagePath,savePathDetect,replacelist,w=savesize[0],h=savesize[1])
77 | print ('Done Save Detected Face Image. step(4/4) optional')
78 | ImagePath=savePathDetect
79 |
80 | print ('Begin making filelist. step (1/6) ')
81 | #创建imagelist.list 文件,用来保存文件图像文件列表
82 | imagelist = './Output/imagelist_recover.list'
83 | fid=open(imagelist,'w')
84 | makeimagelist.makeImageFileList(ImagePath,fid,fileformat)
85 | fid.close()
86 | #统计有多少个图像文件
87 | count=textutil.count_text_line(imagelist)
88 | textutil.insertLine(imagelist,1,str(count))
89 |
90 | print ('Done make file list. step(1/6)')
91 |
92 | #人脸检测,生成imageBbox.list 文件,
93 | print ('Begin Face Detection task. step(2/6)')
94 | bboxlist='./Output/imagebbox__recover.list'
95 | os.system('FaceDetect.exe data '+imagelist+' '+bboxlist)
96 | print ('Done Face Detection task.step(2/6)')
97 |
98 | #清除检测不到的图像,或者检测到多个的文件,以便于后面的人脸关键点检测。
99 | print ('Begin Box file Clean and Replace. step(3/6)')
100 | detectlist='./Output/imagebbox_recover_detect.list'
101 | misslist='./Output/imagebbox_recover_miss.list'
102 | textutil.cleanbox(fileinput=bboxlist,detectlistfile=detectlist,misslistfile=misslist)
103 | replacelist='./Output/imagebbox_detect_recover_replace.list'
104 | textutil.replace_file(detectlist,replacelist,ImagePath)
105 | print ('Done Box file Clean and Replace. step(3/6)')
106 |
107 | #人脸关键点检测
108 | print ('Begin Face Point Detection. step(4/6)' )
109 | resultpath='./Output/result.bin'
110 | command_='FacePointDetect.exe '+replacelist+' '+ImagePath+' Input '+resultpath
111 | os.system(command_)
112 | print ('Done Face Point Detection. step(4/6)')
113 |
114 | print ('Begin write Points files. step(5/6)')
115 | points=textutil.take_out_point(resultpath)
116 | imagepointlist='./Output/imagelist_point.list'
117 | textutil.writePoint2File(replacelist,imagepointlist,points)
118 | print ('Done write Points files. step(5/6)')
119 |
120 | print ('Begin Alignment Face. step(6/6)')
121 | aligment.align_all(imagepointlist,ImagePath,savePathAligned)
122 | print ('Done Alignment Face. step(6/6)')
123 |
124 | print ('Begin Face croped in')
125 | facecrop.face_crop_in(savePathAligned,savePathCroped,replacelist,savesize[0],savesize[1])
126 | print ('Done Face croped in ')
127 | print ('All work is done!')
128 |
129 |
130 | if __name__ == "__main__" :
131 | '''
132 | @param: 提供的参数:1,图像的文件名位置,2,需要保留的文件位置,3,图像的格式列表
133 | '''
134 | #ImagePath=r'./faces/uploadpic_1528272773' #原始的图像路径
135 | #savePathDetect=r'./faces/uploadpic_1528272773/1detect'#保存中间检测到的图像的路径
136 | #savePathAligned=r'./faces/uploadpic_1528272773/2align'#对齐后的人脸图像的保存路径
137 | #savePathCroped=r'./faces/uploadpic_1528272773/3croped'
138 |
139 | Ps = sys.argv[1]
140 | ImagePath=r'./'+Ps+'' #原始的图像路径
141 | savePathDetect=r'./'+Ps+'/1detect'#保存中间检测到的图像的路径
142 | savePathAligned=r'./'+Ps+'/2align'#对齐后的人脸图像的保存路径
143 | savePathCroped=r'./'+Ps+'/3croped'
144 |
145 | test(ImagePath,savePathDetect,savePathAligned,savePathCroped,tag_recover=True,savesize=[256,256])
146 |
--------------------------------------------------------------------------------
/2_getface_ed.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
9 |
10 | ";
28 | echo "
";
29 | echo "
Step 3 →
";
30 |
31 | //$picurl
32 |
33 |
34 | $picurl_1 = $picurl."/3croped/face.jpg";
35 | $picurl_2 = $picurl."/3croped/face.png";
36 |
37 | if(file_exists($picurl_1))
38 | {
39 | //echo "
";
40 | //echo "
";
41 | echo "
";
42 | echo "下一步 人脸特征点提取 →
";
43 | echo "点击后请耐心等待,计算过程大约10秒,期间请不要再次点击,直到右边出现结果
";
44 | }
45 | elseif(file_exists($picurl_2))
46 | {
47 | echo "
";
48 | echo "下一步 人脸特征点提取 →
";
49 | echo "点击后请耐心等待,计算过程大约10秒,期间请不要再次点击,直到右边出现结果
";
50 | }
51 | else
52 | {
53 | echo "没有提取出有效人脸!请回到第一步重新上传包含人脸的图片!";
54 | }
55 |
56 |
57 |
58 | ?>
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/3_facepoint.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
9 |
41 |
42 |
43 |
44 | ";
45 |
46 |
47 |
48 |
49 | ?>
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/3_facepoint.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | import cv2
4 | import dlib
5 |
6 | import sys
7 |
8 | oldpic = sys.argv[1]
9 |
10 | detector = dlib.get_frontal_face_detector()
11 | landmark_predictor = dlib.shape_predictor('shape_predictor_68_face_landmarks.dat')
12 | img = cv2.imread(oldpic)
13 | faces = detector(img,1)
14 | dx = []
15 | dy = []
16 | if (len(faces) > 0):
17 | for k,d in enumerate(faces):
18 | cv2.rectangle(img,(d.left(),d.top()),(d.right(),d.bottom()),(255,255,255))
19 | shape = landmark_predictor(img,d)
20 | for i in range(68):
21 | print(i)
22 | dx.append(shape.part(i).x)
23 | dy.append(shape.part(i).y)
24 | cv2.circle(img, (shape.part(i).x, shape.part(i).y),5,(0,255,0), -1, 8)
25 | cv2.putText(img,str(i),(shape.part(i).x,shape.part(i).y),cv2.FONT_HERSHEY_SIMPLEX,0.5,(255,255,255))
26 | #cv2.imshow('Frame',img)
27 | #cv2.waitKey(0)
28 |
29 |
30 | newpic = oldpic.replace('face.', 'face_68points.')
31 |
32 | cv2.imwrite(newpic,img)
33 |
34 | def getlenof2(x1,y1,x2,y2): #计算两点之间的距离
35 | result = math.sqrt(math.pow(x1-x2,2)+math.pow(y1-y2,2))
36 | return result
37 |
38 | lenof2_36_45 = getlenof2(dx[36],dy[36],dx[45],dy[45])
39 | lenof2_39_42 = getlenof2(dx[39],dy[39],dx[42],dy[42])
40 | lenof2_27_33 = getlenof2(dx[27],dy[27],dx[33],dy[33])
41 | lenof2_31_35 = getlenof2(dx[31],dy[31],dx[35],dy[35])
42 | lenof2_0_16 = getlenof2(dx[0],dy[0],dx[16],dy[16])
43 | lenof2_33_51 = getlenof2(dx[33],dy[33],dx[51],dy[51])
44 | lenof2_57_8 = getlenof2(dx[57],dy[57],dx[8],dy[8])
45 | lenof2_48_54 = getlenof2(dx[48],dy[48],dx[54],dy[54])
46 | lenof2_51_57 = getlenof2(dx[51],dy[51],dx[57],dy[57])
47 | lenof2_66_33 = getlenof2(dx[66],dy[66],dx[33],dy[33])
48 | lenof2_36_45 = getlenof2(dx[36],dy[36],dx[45],dy[45])
49 |
50 | Ap1 = int((lenof2_36_45*10)//lenof2_39_42)
51 | Ap2 = int((lenof2_27_33*10)//lenof2_31_35)
52 | #Ap3 = int((lenof2_39_42*10)//lenof2_27_33)
53 | #Ap4 = int((lenof2_0_16*10)//lenof2_39_42)
54 | #Ap5 = int((lenof2_33_51*10)//lenof2_57_8)
55 | #Ap6 = int((lenof2_48_54*10)//lenof2_51_57)
56 | #Ap7 = int((lenof2_66_33*10)//lenof2_36_45)
57 |
58 | #Ap = str(Ap1)+'_'+str(Ap2)+'_'+str(Ap3)+'_'+str(Ap4)+'_'+str(Ap5)+'_'+str(Ap6)+'_'+str(Ap7)
59 |
60 | Ap = str(Ap1)+'_'+str(Ap2)
61 |
62 | print(Ap)
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/3_facepoint_ed.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
9 |
10 | ";
27 | echo "
";
28 | echo "
Step 4 →
";
29 |
30 | //$picurl
31 |
32 |
33 |
34 | if($Ap!=NULL)
35 | {
36 | echo "
";
37 | $Ap_md5 = md5($Ap);
38 | echo "下一步 在区块链上查询/记录 →
";
39 | }
40 | else
41 | {
42 | echo "未识别出人脸特征点,请换照片!";
43 | echo "返回!";
44 | }
45 |
46 |
47 |
48 |
49 | ?>
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/4_onchain.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
21 |
22 |
23 |
24 |
25 | NasFace
26 |
27 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
Step 5 ↓
39 |
40 |
41 |
42 |
43 |
48 |
49 |
50 | 系统尚无该人脸记录,可该人脸信息
51 |
52 |
53 |
54 |
58 |
59 |
60 |
61 |
62 |
63 |
195 |
196 |
197 |
198 |
199 |
200 |
--------------------------------------------------------------------------------
/FaceDetect.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/FaceDetect.exe
--------------------------------------------------------------------------------
/FacePointDetect.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/FacePointDetect.exe
--------------------------------------------------------------------------------
/Input/Connect_20_40_0.6.txt:
--------------------------------------------------------------------------------
1 | 0 1 0 1 1 0 1 1 0 1 0 0 1 1 0 1 1 1 0 0 0 1 0 0 0 1 1 0 1 1 1 1 1 0 1 0 0 0 1 1
2 | 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 0 1 0
3 | 1 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 1 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 1 0 0 1 1
4 | 0 1 1 1 1 0 1 1 1 1 0 1 0 1 1 1 1 0 0 1 0 0 1 0 0 1 0 1 1 0 0 0 1 0 1 1 1 1 1 0
5 | 0 1 1 1 0 1 0 1 0 0 1 0 0 1 0 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 1 1 1
6 | 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0 1 0 1
7 | 1 1 0 0 1 1 0 1 0 0 1 1 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 0 0 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1 0 1 1 1 1 1 1 0 1 0 0 1 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 1 1 0 0 1 0 0 0 0 0
21 |
--------------------------------------------------------------------------------
/Input/Connect_20_40_1.0.txt:
--------------------------------------------------------------------------------
1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
5 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
6 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
7 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
8 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
9 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
10 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
12 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
13 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
14 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
17 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
19 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
20 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
21 |
--------------------------------------------------------------------------------
/Input/Connect_40_60_0.8.txt:
--------------------------------------------------------------------------------
1 | 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 1 1 1 1 1
2 | 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0 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0 1 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1
36 | 1 1 1 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 0 1 0
37 | 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1
38 | 1 1 0 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1
39 | 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1
40 | 1 1 1 1 0 1 1 0 1 1 1 1 0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41 |
--------------------------------------------------------------------------------
/Input/Net_EN0.txt:
--------------------------------------------------------------------------------
1 | 31 39
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 2
9 | 3
10 | 60
11 | 2
12 | 80
13 | 100
14 | 6
15 | 1 1 2 2 3 2 2 1
16 |
--------------------------------------------------------------------------------
/Input/Net_F0.txt:
--------------------------------------------------------------------------------
1 | 39 39
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 2
9 | 3
10 | 60
11 | 2
12 | 80
13 | 120
14 | 10
15 | 2 2 2 2 3 3 2 2
16 |
--------------------------------------------------------------------------------
/Input/Net_LE1.txt:
--------------------------------------------------------------------------------
1 | 15 15
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 60
9 | 2
10 | 1 1 1 1
11 |
--------------------------------------------------------------------------------
/Input/Net_LM1.txt:
--------------------------------------------------------------------------------
1 | 15 15
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 60
9 | 2
10 | 1 1 1 1
11 |
--------------------------------------------------------------------------------
/Input/Net_N1.txt:
--------------------------------------------------------------------------------
1 | 15 15
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 60
9 | 2
10 | 1 1 1 1
11 |
--------------------------------------------------------------------------------
/Input/Net_NM0.txt:
--------------------------------------------------------------------------------
1 | 31 39
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 2
9 | 3
10 | 60
11 | 2
12 | 80
13 | 100
14 | 6
15 | 1 1 2 2 3 2 2 1
16 |
--------------------------------------------------------------------------------
/Input/Net_RE1.txt:
--------------------------------------------------------------------------------
1 | 15 15
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 60
9 | 2
10 | 1 1 1 1
11 |
--------------------------------------------------------------------------------
/Input/Net_RM1.txt:
--------------------------------------------------------------------------------
1 | 15 15
2 | 2
3 | 4
4 | 20
5 | 2
6 | 3
7 | 40
8 | 60
9 | 2
10 | 1 1 1 1
11 |
--------------------------------------------------------------------------------
/Input/Patch_EN0.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 0 1 2
3 | -2.5 42.5 -2.0 33.77
4 |
--------------------------------------------------------------------------------
/Input/Patch_F0.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 0 1 2 3 4
3 | -2.5 42.5 -2.5 42.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_LE1_13.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 0
3 | -6.5 6.5 -6.5 6.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_LE1_15.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 0
3 | -7.5 7.5 -7.5 7.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_LE2_10.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 0
3 | -5.0 5.0 -5.0 5.0
4 |
--------------------------------------------------------------------------------
/Input/Patch_LE2_9.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 0
3 | -4.5 4.5 -4.5 4.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_LM1_13.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | -6.5 6.5 -6.5 6.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_LM1_15.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | -7.5 7.5 -7.5 7.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_LM2_10.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | -5.0 5.0 -5.0 5.0
4 |
--------------------------------------------------------------------------------
/Input/Patch_LM2_9.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | -4.5 4.5 -4.5 4.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_N1_13.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | -6.5 6.5 -6.5 6.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_N1_15.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | -7.5 7.5 -7.5 7.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_N2_10.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | -5.0 5.0 -5.0 5.0
4 |
--------------------------------------------------------------------------------
/Input/Patch_N2_9.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | -4.5 4.5 -4.5 4.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_NM0.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 2 3 4
3 | -2.5 42.5 6.73 42.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_RE1_13.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1
3 | -6.5 6.5 -6.5 6.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_RE1_15.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1
3 | -7.5 7.5 -7.5 7.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_RE2_10.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1
3 | -5.0 5.0 -5.0 5.0
4 |
--------------------------------------------------------------------------------
/Input/Patch_RE2_9.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1
3 | -4.5 4.5 -4.5 4.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_RM1_13.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 4
3 | -6.5 6.5 -6.5 6.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_RM1_15.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 4
3 | -7.5 7.5 -7.5 7.5
4 |
--------------------------------------------------------------------------------
/Input/Patch_RM2_10.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 4
3 | -5.0 5.0 -5.0 5.0
4 |
--------------------------------------------------------------------------------
/Input/Patch_RM2_9.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 4
3 | -4.5 4.5 -4.5 4.5
4 |
--------------------------------------------------------------------------------
/Input/Weight_EN0.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_EN0.bin
--------------------------------------------------------------------------------
/Input/Weight_F0.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_F0.bin
--------------------------------------------------------------------------------
/Input/Weight_LE1_13.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LE1_13.bin
--------------------------------------------------------------------------------
/Input/Weight_LE1_15.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LE1_15.bin
--------------------------------------------------------------------------------
/Input/Weight_LE2_10.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LE2_10.bin
--------------------------------------------------------------------------------
/Input/Weight_LE2_9.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LE2_9.bin
--------------------------------------------------------------------------------
/Input/Weight_LM1_13.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LM1_13.bin
--------------------------------------------------------------------------------
/Input/Weight_LM1_15.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LM1_15.bin
--------------------------------------------------------------------------------
/Input/Weight_LM2_10.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LM2_10.bin
--------------------------------------------------------------------------------
/Input/Weight_LM2_9.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_LM2_9.bin
--------------------------------------------------------------------------------
/Input/Weight_N1_13.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_N1_13.bin
--------------------------------------------------------------------------------
/Input/Weight_N1_15.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_N1_15.bin
--------------------------------------------------------------------------------
/Input/Weight_N2_10.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_N2_10.bin
--------------------------------------------------------------------------------
/Input/Weight_N2_9.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_N2_9.bin
--------------------------------------------------------------------------------
/Input/Weight_NM0.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_NM0.bin
--------------------------------------------------------------------------------
/Input/Weight_RE1_13.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RE1_13.bin
--------------------------------------------------------------------------------
/Input/Weight_RE1_15.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RE1_15.bin
--------------------------------------------------------------------------------
/Input/Weight_RE2_10.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RE2_10.bin
--------------------------------------------------------------------------------
/Input/Weight_RE2_9.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RE2_9.bin
--------------------------------------------------------------------------------
/Input/Weight_RM1_13.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RM1_13.bin
--------------------------------------------------------------------------------
/Input/Weight_RM1_15.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RM1_15.bin
--------------------------------------------------------------------------------
/Input/Weight_RM2_10.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RM2_10.bin
--------------------------------------------------------------------------------
/Input/Weight_RM2_9.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Input/Weight_RM2_9.bin
--------------------------------------------------------------------------------
/Output/imagebbox.list:
--------------------------------------------------------------------------------
1 | ./faces/uploadpic_1528644489\face.jpg 53 202 108 258
2 |
--------------------------------------------------------------------------------
/Output/imagebbox__recover.list:
--------------------------------------------------------------------------------
1 | ./faces/uploadpic_1528644489/1detect\face.jpg 58 191 60 193
2 |
--------------------------------------------------------------------------------
/Output/imagebbox_detect.list:
--------------------------------------------------------------------------------
1 | ./faces/uploadpic_1528644489\face.jpg 53 202 108 258
2 |
--------------------------------------------------------------------------------
/Output/imagebbox_detect_recover_replace.list:
--------------------------------------------------------------------------------
1 | \face.jpg 58 191 60 193
2 |
--------------------------------------------------------------------------------
/Output/imagebbox_detect_replace.list:
--------------------------------------------------------------------------------
1 | \face.jpg 53 202 108 258
2 |
--------------------------------------------------------------------------------
/Output/imagebbox_miss.list:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Output/imagebbox_miss.list
--------------------------------------------------------------------------------
/Output/imagebbox_recover_detect.list:
--------------------------------------------------------------------------------
1 | ./faces/uploadpic_1528644489/1detect\face.jpg 58 191 60 193
2 |
--------------------------------------------------------------------------------
/Output/imagebbox_recover_miss.list:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Output/imagebbox_recover_miss.list
--------------------------------------------------------------------------------
/Output/imagelist.list:
--------------------------------------------------------------------------------
1 | 1
2 | ./faces/uploadpic_1528644489\face.jpg
3 |
--------------------------------------------------------------------------------
/Output/imagelist_point.list:
--------------------------------------------------------------------------------
1 | \face.jpg 88 93 162 93 125 136 95 165 158 164
2 |
--------------------------------------------------------------------------------
/Output/imagelist_recover.list:
--------------------------------------------------------------------------------
1 | 1
2 | ./faces/uploadpic_1528644489/1detect\face.jpg
3 |
--------------------------------------------------------------------------------
/Output/readme.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Output/readme.md
--------------------------------------------------------------------------------
/Output/result.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/Output/result.bin
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ##
2 | # 人脸识别on区块链
3 | #
4 | #
5 | #
6 | #
7 | ## http://NasFace.com 或 http://180.76.136.150/
8 | ##
9 | ### 本作品提供一套完整的【人脸识别】解决方案,并使用【区块链】存储和查询人脸特征数据,可广泛应用于各种场景,如【人脸锁】。
10 | ### 本作品区块链方案采用[星云链Nebulas](https://nebulas.io/),请在开始使用前安装好[WebExtensionWallet](https://github.com/ChengOrangeJu/WebExtensionWallet)并创建账户后刷新,再开始操作。否则一系列的前期操作结果最终将无法与区块链交互,以至体验不到本作品运用区块链的核心意义。
11 | ### [开源代码&演示文档](https://github.com/lawup/nasface)
12 | ### [区块链合约](https://explorer.nebulas.io/#/tx/3fb368b822c91506c0a58593e08b5bf9922a84f72c7469c5e36053312e6bc7de)
13 | ##
14 | ##
15 | ## Step1 上传一张图片
16 | ### 选择一张图片,点击【确认上传 → 】
17 | ### 单张不超过2M 支持jpg、png格式文件
18 | ##
19 | ## Step2 人脸提取并对齐
20 | ### 待上传的图片显示出来,点击【下一步 人脸提取并对齐 → 】
21 | ### 点击一次后请耐心等待,计算过程大约一分钟,期间请不要再次点击,直到右边出现结果
22 | ### 后台运行的【人脸检测&对齐&裁剪】等归一化能力由[FaceTools](https://github.com/RiweiChen/FaceTools)提供
23 | ##
24 | ## Step3 人脸特征点提取
25 | ### 待人脸提取并对齐的结果图片显示出来,点击【下一步 人脸特征点提取 → 】
26 | ### 点击后请耐心等待,计算过程大约10秒,期间请不要再次点击,直到右边出现结果
27 | ### 后台运行的【人脸68个特征点的提取】,能力由[dlib](http://dlib.net)提供
28 | ### 提取人脸的68个特征点之后,系统会据此计算7个自定义的特征比例(同一个人脸的不同照片,特征比例将是确定的,因此可作为同一认定的依据。当然在目前的演示中,为了较好的用户体验,仅用了2个特征点比例,这样做降低了识别门槛,但在实际运用中会降低安全性,也有可能造成误识别),据此7项特征比例数据整体生成一个哈希值(为保护隐私,不提倡明文。若在正式应用中,可用pyc文件代替py文件,即可最大限度保护用户隐私)
29 | ##
30 | ## Step4 在区块链上查询/记录
31 | ### 待上一步计算完成,可点击【下一步 在区块链上查询/记录 →】进入Step5
32 | ##
33 | ## Step5-1 查询
34 | ### 点击【查询 看看Ta是谁】按钮,系统会查询区块链网络,将结果反馈:
35 | ### 若已有记录,则反馈【内容(一般是该脸的主人的姓名,如“张三”)】及【记录人(提交内容的区块链钱包账号)】
36 | ## Step5-2 记录
37 | ### 若点击【查询 看看Ta是谁】按钮,系统中没有查到相应记录,则会反馈:系统尚无该人脸记录,可【添加】该人脸信息
38 | ### 那么,点击【添加】,可在得到的输入框中输入脸主人的名字,再点击【提交数据到区块链上】,可调起[WebExtensionWallet](https://github.com/ChengOrangeJu/WebExtensionWallet)(因此事前应将其装好并创建钱包账户,账户中需有少许NAS币,大约0.0001就够,如果没有可微信作者71520977索要),在弹出框中【Unlock】了钱包账户的前提下,依次点击【Confirm】和【Submit】即可,然后等待数秒,数据即成功提交到区块链上了。
39 | ### 之后,再点击【查询 看看Ta是谁】按钮时,系统就会查询到刚刚提交的人脸信息了。(如果这是一个【人脸锁】的应用的话,这一步相当于是注册,而【查询】可以认为是在验证人脸)
40 | ##
41 | ##
42 | ## 运行环境
43 | ### windows10 ([FaceTools](https://github.com/RiweiChen/FaceTools)需要在windows下运行)
44 | ### php5.4 (需要打开exec(),即在PHP.ini中去掉disable_functions行的exec项)
45 | ### python3.5.3
46 | ### dlib19.4.0 (可下载安装编译好的whl文件dlib-19.4.0-cp35-cp35m-win_amd64.whl ,避免繁琐编译,下载链接:https://pan.baidu.com/s/1KSCF2r_Lt71l2aOpKoS0HA 密码:qn54 )
47 | ### dlib要用到的人脸库 shape_predictor_68_face_landmarks.dat 在[这里下载](http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2) ,下载后放在本程序根目录中即可
48 | ###
49 | ###
50 | ### 需要说明的是,本作品仅是个实验作品,有关人脸识别的准确率和区块链的运行效率及可行性,尚在探讨中。
51 | ### 欢迎与作者联系,微信:71520977
52 | ###
53 |
54 |
--------------------------------------------------------------------------------
/aligment.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Created on Fri May 29 20:01:59 2015
4 |
5 | @author: Chenriwei
6 | @brief: 根据检测到的点,对其人脸图像
7 | """
8 | import cv2
9 | import os
10 | import numpy as np
11 | import matplotlib.pylab as plt
12 | import skimage
13 | from skimage import transform as tf
14 | from skimage import io
15 | def compute_affine_transform(refpoints, points, w = None):
16 | '''
17 | 计算仿射变换矩阵
18 | '''
19 | if w == None:#每个关键点的权重
20 | w = [1] * (len(points) * 2)
21 | assert(len(w) == 2*len(points))
22 | y = []
23 | for n, p in enumerate(refpoints):
24 | y += [p[0]/w[n*2], p[1]/w[n*2+1]]
25 | A = []
26 | for n, p in enumerate(points):
27 | A.extend([ [p[0]/w[n*2], p[1]/w[n*2], 0, 0, 1/w[n*2], 0], [0, 0, p[0]/w[n*2+1], p[1]/w[n*2+1], 0, 1/w[n*2+1]] ])
28 |
29 | lstsq = cv2.solve(np.array(A), np.array(y), flags=cv2.DECOMP_SVD)
30 | h11, h12, h21, h22, dx, dy = lstsq[1]
31 | #err = 0#lstsq[1]
32 |
33 | #R = np.array([[h11, h12, dx], [h21, h22, dy]])
34 | # The row above works too - but creates a redundant dimension
35 | R = np.array([[h11[0], h12[0], dx[0]], [h21[0], h22[0], dy[0]]])
36 | return R#, err
37 |
38 | def alignment(filename,points,ref_points):
39 | '''
40 | @brief: 根据检测到的点,对其人脸图像
41 | '''
42 | assert(len(points)==len(ref_points))
43 | num_point=len(ref_points)//2
44 | #参考图像的点
45 | dst=np.empty((num_point,2),dtype=np.int)
46 | k=0
47 | for i in range(num_point):
48 | for j in range(2):
49 | dst[i][j]=ref_points[k]
50 | k=k+1
51 | #待对齐图像的点
52 | src=np.empty((num_point,2),dtype=np.int)
53 | k=0
54 | for i in range(num_point):
55 | for j in range(2):
56 | src[i][j]=points[k]
57 | k=k+1
58 | #根据检测到的点,求其相应的仿射变换矩阵
59 | tfrom=tf.estimate_transform('affine',dst,src)
60 | #用opencv的试试,其只能采用三个点,计算矩阵M
61 | # pts1 = np.float32([[src[0][0],src[0][1]],[src[1][0],src[1][1]],[src[2][0],src[2][1]]])
62 | # pts2 = np.float32([[dst[0][0],dst[0][1]],[dst[1][0],dst[1][1]],[dst[2][0],dst[2][1]]])
63 | # M = cv2.getAffineTransform(pts2,pts1)
64 | #用最小二乘法的方法进行处理
65 | pts3 = np.float32([[src[0][0],src[0][1]],[src[1][0],src[1][1]],[src[2][0],src[2][1]],[src[3][0],src[3][1]],[src[4][0],src[4][1]]])
66 | pts4 = np.float32([[dst[0][0],dst[0][1]],[dst[1][0],dst[1][1]],[dst[2][0],dst[2][1]],[dst[3][0],dst[3][1]],[dst[4][0],dst[4][1]]])
67 | N = compute_affine_transform(pts4,pts3)
68 | #
69 | im=skimage.io.imread(filename)
70 | if im.ndim==3:
71 | rows,cols,ch = im.shape
72 | else:
73 | rows,cols = im.shape
74 | warpimage_cv2 = cv2.warpAffine(im,N,(cols,rows))
75 | warpimage=tf.warp(im,inverse_map=tfrom)
76 |
77 | return warpimage,warpimage_cv2
78 |
79 | def align_all(filelist,imageRootPath,savePath):
80 | '''
81 | @breif:对其所有的人脸图像,需要选择参考的图像,默认为第一张
82 | '''
83 | fid=open(filelist)
84 | for i in range(1):
85 | line=fid.readline()
86 | word=line.split()
87 | print ('reference image:'+imageRootPath+word[0])
88 | fid.close()
89 | #随机选择一个参考图像和参考点
90 | #todo:人工选择一张比较合适的图像作为参考图像,默认情况下,第一张作为参考图像
91 | ref_points=np.empty((10,1),dtype=np.int)
92 | points=np.empty((10,1),dtype=np.int)
93 | filename=word[0]
94 | for i in range(10):
95 | ref_points[i]=int(word[i+1])
96 | refimage=skimage.io.imread(imageRootPath+word[0])
97 | if refimage.ndim==3:
98 | rows,cols,ch = refimage.shape
99 | else:
100 | rows,cols = refimage.shape
101 | #rows,cols,ch = refimage.shape
102 | #为保留数据的完整性,重新扫描
103 | fid=open(filelist,'r')
104 | lines=fid.readlines()
105 | for line in lines:
106 | word=line.split()
107 | filename=word[0]
108 | for j in range(10):
109 | points[j]=int(word[j+1])
110 | #originimage=skimage.io.imread(imageRootPath+filename)
111 | warpimage,warpimage_cv2=alignment(imageRootPath+filename,points,ref_points)
112 | savename=savePath+filename
113 | #处理多层文件,不能写入的问题,新建文件
114 | dirname, basename = os.path.split(savename)
115 | if not os.path.exists(dirname):
116 | os.makedirs(dirname)
117 | if warpimage_cv2.shape== refimage.shape:
118 | skimage.io.imsave(savename,warpimage_cv2)
119 | else:
120 | if warpimage_cv2.ndim==3:
121 | rows,cols,ch = warpimage_cv2.shape
122 | skimage.io.imsave(savename,warpimage_cv2[0:rows,0:cols,:])
123 | else:
124 | rows,cols = warpimage_cv2.shape
125 | skimage.io.imsave(savename,warpimage_cv2[0:rows,0:cols])
126 |
127 | fid.close()
128 | if __name__=='__main__':
129 | imageRootPath=r'F:\Dataset\MORPH'
130 | savePath=r'F:\MyDataset\MORPH\face_aligned_5_points'
131 | fid=open('imageListWithPoints.list','r')
132 | for i in range(2):
133 | line=fid.readline()
134 | word=line.split()
135 | print ('reference image:',word)
136 | fid.close()
137 |
138 | #随机选择一个参考图像和参考点
139 | #todo:人工选择一张比较合适的图像作为参考图像,默认情况下,第一张作为参考图像
140 | ref_points=np.empty((10,1),dtype=np.int)
141 | points=np.empty((10,1),dtype=np.int)
142 | filename=word[0]
143 | for i in range(10):
144 | ref_points[i]=int(word[i+1])
145 | #while fid.readline()==
146 | refimage=skimage.io.imread(imageRootPath+word[0])
147 |
148 | plt.subplot(1,3,1)
149 | plt.imshow(refimage)
150 | plt.axis('off')
151 | rows,cols,ch = refimage.shape
152 |
153 | fid=open('imageListWithPoints.list','r')
154 | lines=fid.readlines()
155 | for line in lines:
156 | #for i in range(1000):
157 | #word=fid.readline().split()
158 | word=line.split()
159 | filename=word[0]
160 | for j in range(10):
161 | points[j]=int(word[j+1])
162 | originimage=skimage.io.imread(imageRootPath+filename)
163 | warpimage,warpimage_cv2=alignment(imageRootPath+filename,points,ref_points)
164 |
165 | # plt.subplot(1,3,2)
166 | # plt.imshow(warpimage)
167 | # plt.axis('off')
168 | # plt.subplot(1,3,3)
169 | # plt.imshow(warpimage_cv2)
170 | # plt.axis('off')
171 | #warpimage=tf.resize(warpimage,(200,200))
172 | #todo: 处理大小不同图像的输出
173 | if warpimage_cv2.shape== refimage.shape:
174 | skimage.io.imsave(savePath+filename,warpimage_cv2)
175 | else:
176 | skimage.io.imsave(savePath+filename,warpimage_cv2[0:rows,0:cols,:])
177 | fid.close()
--------------------------------------------------------------------------------
/blank.htm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/blank.htm
--------------------------------------------------------------------------------
/cleanBoxFile.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Created on Sat Jan 10 23:41:55 2015
4 |
5 | @author: Chenriwei
6 |
7 | 功能:处理 Box.txt 文件里面的内容
8 | """
9 |
10 | import numpy as np
11 |
12 | def retain_max_face(line):
13 | '''
14 | @param:行内容
15 | @return:返回新的行内容
16 | '''
17 | word=line.split()
18 | num_detect=len(word)/4
19 | areas=np.empty((num_detect,),dtype=np.int32)#保留的是图像的面积
20 | for i in range(num_detect):
21 | #print int(word[4*i+1]),int(word[4*i+2]),int(word[4*i+3]),int(word[4*i+4])
22 | areas[i]=(int(word[4*i+2])-int(word[4*i+1]))*(int(word[4*i+4])-int(word[4*i+3]))
23 | print areas[i]
24 | m=np.argmax(areas)
25 | newline=word[0]+' '+word[4*m+1]+' '+word[4*m+2]+' '+word[4*m+3]+' '+word[4*m+4]+'\n'
26 | return newline
27 |
28 | def cleanBoxFile(fileinput="imageBbox.list",detectlistfile="imageBbox_detect.list",misslistfile="imageBbox_miss.list"):
29 | '''
30 | 清除掉没有检测到的人脸图像,或者检测到多个人脸的图像
31 | 因为只需要考虑单个人脸即可
32 | 对于多个人脸的情况,可以后面再补充进来。
33 | '''
34 | file0_obj=open(file0,'r')
35 | file1_obj=open(file1,'w')
36 | file2_obj=open(file2,'w')
37 | lines=file0_obj.readlines()
38 | for line in lines:
39 | print line
40 | if line.count(" ")==4:
41 | file1_obj.write(line)
42 | else:
43 | if line.count(" ")>4:#表明有多个人脸被检测到
44 | newline=retain_max_face(line)
45 | file1_obj.write(newline)
46 | else:
47 | file2_obj.write(line)
48 | file0_obj.close()
49 | file1_obj.close()
50 | file2_obj.close()
51 | print 'done!'
52 | if __name__ == "__main__" :
53 | cleanBoxFile()
--------------------------------------------------------------------------------
/data/detector_lfp.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/data/detector_lfp.dat
--------------------------------------------------------------------------------
/data/svmpostfilter_lfp.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/data/svmpostfilter_lfp.dat
--------------------------------------------------------------------------------
/demo0.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/demo0.JPG
--------------------------------------------------------------------------------
/demo1.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lawup/nasface/de111a7910cf286322516fe2e6abdcb1fa112306/demo1.JPG
--------------------------------------------------------------------------------
/facecrop.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Created on Sat May 30 10:26:07 2015
4 |
5 | @author: Chenriwei
6 | """
7 | from skimage import transform as tf
8 | import numpy as np
9 | import skimage
10 | import os
11 | def face_cropout(srcPath,dstPath,filelist='imageBbox_detect_replace.list',enlarge=True,w=256,h=256):
12 | '''
13 | @enlarge:是否扩大检测到的人脸图像区域,一般都偏小。
14 |
15 | '''
16 | fid=open(filelist)
17 | lines=fid.readlines()
18 | fid.close()
19 | for line in lines:
20 | word=line.split()
21 | filename=word[0]
22 | x1=int(word[1])
23 | x2=int(word[2])
24 | y1=int(word[3])
25 | y2=int(word[4])
26 |
27 | a1=x1
28 | a2=x2
29 | b1=y1
30 | b2=y2
31 | im=skimage.io.imread(srcPath+filename)
32 | if im.ndim==3:
33 | rows,cols,ch = im.shape
34 | else:
35 | rows,cols = im.shape
36 | if enlarge==True:
37 | a1= (x1-(x2-x1)//2) if (x1-(x2-x1)//2)>=0 else 0
38 | b1= (y1-(y2-y1)//2) if (y1-(y2-y1)//2)>=0 else 0
39 | a2= (x2+(x2-x1)//2) if (x2+(x2-x1)//2)
2 |
3 |
4 |
5 | NasFace
6 |
7 |
8 |
19 |
20 |