-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3d51be
commit 52112bb
Showing
74 changed files
with
178 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Face Recognition via Eigenface | ||
```sh | ||
1. PCA to compute eigenface, show eigenface images | ||
2. Project a face image into the face space, show the reconstructed face | ||
3. Face Detection: finding the size and position of a face in an image | ||
4. Face Recognition: Find the person in the training set for each detected face. | ||
``` | ||
|
||
# Effect | ||
#### smiling | ||
 | ||
 | ||
#### nonsmiling | ||
 | ||
 | ||
|
||
# Usage | ||
## Get results | ||
#### Step1 | ||
```sh | ||
Modify <line15~17> in <main.m> according to your needs. | ||
``` | ||
#### Step2 | ||
```sh | ||
Run main.m to get the results. | ||
``` | ||
## Show results | ||
```sh | ||
Modify <line10~12> in <showResults.m> according to your needs. | ||
``` | ||
#### Step2 | ||
```sh | ||
Run showResults.m to show the results. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
%{ | ||
Author: | ||
Charles | ||
Function: | ||
Choose one of the rois that matched to the same face according to their match distance. | ||
Input: | ||
-face_coordinates: unfiltered face_coordinates. | ||
-dists_det: unfiltered dists_det. | ||
-dists_rec: unfiltered dists_rec. | ||
Output: | ||
-face_coordinates: filtered face_coordinates. | ||
-dists_det: filtered dists_det. | ||
-dists_rec: filtered dists_rec. | ||
%} | ||
function [face_coordinates_new, dists_det_new, dists_rec_new] = filterFace(face_coordinates, dists_det, dists_rec) | ||
face_coordinates_new = []; | ||
dists_det_new = []; | ||
dists_rec_new = []; | ||
reco_labels = unique(dists_rec(:, 1)); | ||
for i = 1: length(reco_labels) | ||
index = find(dists_rec(:, 1) == reco_labels(i)); | ||
face_coordinate = face_coordinates(index, :); | ||
dist_det = dists_det(index, :); | ||
dist_rec = dists_rec(index, 2); | ||
dist_rec2 = dists_rec(index, :); | ||
index = find(dist_rec == min(dist_rec)); | ||
face_coordinates_new = [face_coordinates_new; face_coordinate(index, :)]; | ||
dists_det_new = [dists_det_new; dist_det(index, :)]; | ||
dists_rec_new = [dists_rec_new; dist_rec2(index, :)]; | ||
end | ||
[~, index] = sort(dists_rec_new(:, 2)); | ||
face_coordinates_new = face_coordinates_new(index, :); | ||
dists_det_new = dists_det_new(index, :); | ||
dists_rec_new = dists_rec_new(index, :); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.12 KB
Application/Face Recognition/results/nonsmiling/1_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.53 KB
Application/Face Recognition/results/nonsmiling/2_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+780 Bytes
Application/Face Recognition/results/nonsmiling/3_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+4.65 KB
Application/Face Recognition/results/nonsmiling/4_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+367 Bytes
Application/Face Recognition/results/nonsmiling/5_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+376 Bytes
Application/Face Recognition/results/nonsmiling/6_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+378 Bytes
Application/Face Recognition/results/nonsmiling/7_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.5 KB
Application/Face Recognition/results/nonsmiling/reconstructedfaces.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+399 Bytes
Application/Face Recognition/results/smiling/1_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1003 Bytes
Application/Face Recognition/results/smiling/2_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+377 Bytes
Application/Face Recognition/results/smiling/3_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+292 Bytes
Application/Face Recognition/results/smiling/4_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+355 Bytes
Application/Face Recognition/results/smiling/5_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+314 Bytes
Application/Face Recognition/results/smiling/6_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+291 Bytes
Application/Face Recognition/results/smiling/7_face_coordinates.mat
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
%{ | ||
Author: | ||
Charles | ||
Function: | ||
Show the results of face detection and recognition. | ||
%} | ||
close all; | ||
clear; | ||
OUTPATH = './results/'; | ||
TRAINDATA = 'nonsmiling'; | ||
addpath('./utils'); | ||
iou_thresh = 0.5; | ||
num = 7; | ||
for img_idx = 1: num | ||
img_path = [OUTPATH TRAINDATA '/' num2str(img_idx) '.jpg']; | ||
img = imread(img_path); | ||
figure(); | ||
imshow(img); | ||
load([OUTPATH TRAINDATA '/' num2str(img_idx) '_face_coordinates.mat']); | ||
load([OUTPATH TRAINDATA '/' num2str(img_idx) '_dists_det.mat']); | ||
load([OUTPATH TRAINDATA '/' num2str(img_idx) '_dists_rec.mat']); | ||
[face_coordinates, dists_det, dists_rec] = filterFace(face_coordinates, dists_det, dists_rec); | ||
coordinates = {}; | ||
count = 0; | ||
for i = 1: size(face_coordinates, 1) | ||
hold on; | ||
color = 'green'; | ||
if isempty(coordinates) | ||
rectangle('Position', face_coordinates(i, :), 'edgecolor', color); | ||
text(face_coordinates(i, 1) - 5, face_coordinates(i, 2) - 5, num2str(dists_rec(i, 1)), 'color', color); | ||
coordinates = [coordinates, face_coordinates(i, :)]; | ||
count = count + 1; | ||
else | ||
flag = true; | ||
for j = 1: length(coordinates) | ||
if bboxIoU(coordinates{j}, face_coordinates(i, :)) > iou_thresh | ||
flag = false; | ||
break | ||
end | ||
end | ||
if flag | ||
rectangle('Position', face_coordinates(i, :), 'edgecolor', color); | ||
text(face_coordinates(i, 1) - 5, face_coordinates(i, 2) - 5, num2str(dists_rec(i, 1)), 'color', color); | ||
coordinates = [coordinates, face_coordinates(i, :)]; | ||
count = count + 1; | ||
end | ||
end | ||
if count == 3 | ||
break | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
%{ | ||
Author: | ||
Charles | ||
Function: | ||
Compute iou. | ||
Input: | ||
-box1: one of the boxes, (top_left_x, top_left_y, width, height). | ||
-box2: one of the boxes, (top_left_x, top_left_y, width, height). | ||
Output: | ||
-iou: IoU = Overlapping area / (two boxes' total area - Overlapping area). | ||
%} | ||
function iou = bboxIoU(box1, box2) | ||
mx = min(box1(1), box2(1)); | ||
Mx = max(box1(1)+box1(3), box2(1)+box2(3)); | ||
my = min(box1(2), box2(2)); | ||
My = max(box1(2)+box1(4), box2(2)+box2(4)); | ||
w1 = box1(3); | ||
h1 = box1(4); | ||
w2 = box2(3); | ||
h2 = box2(4); | ||
uw = Mx - mx; | ||
uh = My - my; | ||
cw = w1 + w2 - uw; | ||
ch = h1 + h2 - uh; | ||
if cw <=0 || ch <= 0 | ||
iou = 0; | ||
else | ||
area1 = w1 * h1; | ||
area2 = w2 * h2; | ||
carea = cw * ch; | ||
uarea = area1 + area2 - carea; | ||
iou = carea / uarea; | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters