Skip to content

Commit 20f2dcc

Browse files
new
1 parent 1400ce3 commit 20f2dcc

File tree

12 files changed

+88
-26
lines changed

12 files changed

+88
-26
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ Facial key-points detection by using CNN model. Dataset:FG-Net
1111
<img src="images/Figure_4.png" width="320" height="240">
1212
<img src="images/Figure_5.png" width="320" height="240">
1313
<img src="images/Figure_2.png" width="320" height="240">
14+
<img src="images/Figure_7.png" width="320" height="240">
15+
<img src="images/Figure_11.png" width="320" height="240">
16+
<img src="images/Figure_12.png" width="320" height="240">
17+
<img src="images/Figure_13.png" width="320" height="240">

commonModule/ImageBase.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from matplotlib import pyplot as plt
66

77
def changeBgr2Rbg(img): #input color img
8-
b,g,r = cv2.split(img) # get b,g,r
9-
img = cv2.merge([r,g,b])
8+
if getImagChannel(img) == 3:
9+
b,g,r = cv2.split(img) # get b,g,r
10+
img = cv2.merge([r,g,b])
1011
return img
1112

1213
def loadImg(file,mode=cv2.IMREAD_COLOR):

faceIdentification.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def CascadeDetect(cascPath=r'./res/haarcascade_frontalface_default.xml'):
2121

2222
def main():
2323
cv2.useOptimized()
24-
file = r'./res/obama.jpg'#r'./res/Lenna.png' #
24+
file = r'./res/trump.jpg'#r'./res/Lenna.png' #obama.jpg
2525

2626
print('Number of parameter:', len(sys.argv))
2727
print('Parameters:', str(sys.argv))
@@ -32,11 +32,15 @@ def main():
3232
img = loadImg(file,mode=cv2.IMREAD_COLOR) # IMREAD_GRAYSCALE IMREAD_COLOR
3333

3434
faceROI = CascadeDetect()
35-
3635
faceR=faceROI.getDetectImg(img)
3736
face = faceROI.detecvFaceImgOne(img)
3837
faceGray = cv2.cvtColor(face, cv2.COLOR_BGR2GRAY)
3938

39+
img = changeBgr2Rbg(img)
40+
faceR = changeBgr2Rbg(faceR)
41+
#face = changeBgr2Rbg(face)
42+
#faceGray = changeBgr2Rbg(faceGray)
43+
4044
ls,names = [],[]
4145
ls.append(img),names.append('orignal')
4246
ls.append(faceR),names.append('faceR')
@@ -46,7 +50,7 @@ def main():
4650
plotImagList(ls,names)
4751

4852
#faceGray = resizeImg(faceGray,newW,newH)
49-
#img.writeImg(face,'./res/myface_.png')
53+
writeImg(face,'./res/myface_.png')
5054
#writeImg(faceGray,'./res/myface_gray.png')
5155

5256
if __name__=="__main__":

images/Capture.PNG

33.9 KB
Loading

images/Figure_11.png

161 KB
Loading

images/Figure_12.png

232 KB
Loading

images/Figure_13.png

382 KB
Loading

images/Figure_7.png

370 KB
Loading

predictKeyPoints.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def argCmdParse():
1919
def preditImg(img, modelName = r'./weights/trainFacialRecognition.h5'): # #r'./weightLoc/trainFacialRecognition.h5'
2020
model = ks.models.load_model(modelName)
2121
print(img.shape)
22-
x = img[:,:,0]
22+
if getImagChannel(img) == 3:
23+
x = img[:,:,0]
24+
else:
25+
x = img
26+
2327
print(x.shape)
2428
x = x.reshape((1,x.shape[0],x.shape[1],1))
2529
print(x.shape)

predictPerson.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def predictPerson(feature):
3636

3737
def main():
3838
arg = argCmdParse()
39-
file = r'./res/001A29_ex2.jpg' #r'./res/001A29.jpg' #arg.source #
39+
file = r'./res/myface_.png' #r'./res/001A29_ex2.jpg' #r'./res/001A29.jpg' #arg.source #
4040

4141
img = loadImg(file)
4242
img = resizeImg(img,newW,newH)

0 commit comments

Comments
 (0)