-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
26 lines (20 loc) · 839 Bytes
/
example.py
File metadata and controls
26 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from PIL import Image
from CreateDatabase import CreateDatabase
from EigenfaceCore import EigenfaceCore
from Recognition import Recognition
homePath = r'E:\pycharm files\基于PCA的人脸识别\\'
TrainDatabase = r"TrainDatabase\\"
T = CreateDatabase(homePath+TrainDatabase)
m,A,Eigenfaces = EigenfaceCore(T)
# 输入测试图片
TestImage = input('Enter test image name (a number between 1 to 10): ')
TestImage = 'TestDatabase\\' + TestImage + '.jpg'
OutputName=Recognition(homePath+TestImage, m, A, Eigenfaces)
print("Matched image is:",str(OutputName)+".jpg")
# 绘制测试图片
image_test = Image.open(homePath+TestImage)
image_test.show()
# 绘制匹配到的图片
SelectedImage = homePath + r"TrainDatabase\\" +str(OutputName) + ".jpg"
image_select = Image.open(SelectedImage)
image_select.show()