Face Liveness detection ....

1 view (last 30 days)
priti kale
priti kale on 20 May 2019
Commented: Rik on 20 May 2019
my code is below in which live face crop mannualy after that crop face shows then I crop manually skin of that face and save in 50 by 50 pixel and then I have to comapre that skin image having size 50 by 50 with my two database One of them database is of 50 images is fake face skin by mobile captured another database is live face skin captured by webcam. I have to compare with that live skin image with two database what to do...?? my code is
vid = videoinput('winvideo', 1);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
imshow(img)
j= imcrop(img);
imshow(j);
k= imcrop(j);
imshow(k)
test =imresize(k,[50 50]);
figure, imshow(test);
newName = strcat(num2str(1),'.jpg');
imwrite(test,['test\' newName,]);
testpath = 'C:\Users\PRITI KALE\Desktop\rani\test';
TestImage = strcat(testpath,'\','1.jpg');
D = dir(TestImage);
imgcount = 0;
for i=1 : size(D,1)
if not(strcmp(D(i).name,'.')|strcmp(D(i).name,'..')|strcmp(D(i).name,'Thumbs.db'))
imgcount1 = imgcount + 1; % Number of all images in the training database
end
end
str = strcat(TestImage ,'\',int2str(i),'.jpg');
img = imread(TestImage);
img = rgb2gray(img);
glcm2 = graycomatrix(img);
stats1 = graycoprops(glcm2);
live1(i)=stats1.Homogeneity;
Datapath2 = 'C:\Users\PRITI KALE\Desktop\rani\fake\Fake'; % path of program files and data on your pc
disp 'start....'
disp 'reading dataset...'
D = dir(Datapath2);
imgcount1 = 0;
for i=1 : size(D,1)
if not(strcmp(D(i).name,'.')|strcmp(D(i).name,'..')|strcmp(D(i).name,'Thumbs.db'))
imgcount2 = imgcount1 + 1; % Number of all images in the training database
end
end
for i = 1 :50
str = strcat(Datapath2,'\',int2str(i),'.jpg');
img = imread(str);
img = rgb2gray(img);
glcm2 = graycomatrix(img);
stats2 = graycoprops(glcm2);
fake(i)=stats2.Homogeneity; %#ok<SAGROW>
end
Datapath2 = 'C:\Users\PRITI KALE\Desktop\rani\live\Live'; % path of program files and data on your pc
disp 'start....'
disp 'reading dataset...'
D = dir(Datapath2);
imgcount2 = 0;
for i=1 : size(D,1)
if not(strcmp(D(i).name,'.')|strcmp(D(i).name,'..')|strcmp(D(i).name,'Thumbs.db'))
imgcount3 = imgcount2 + 1; % Number of all images in the training database
end
end
for i = 1 :50
str = strcat(Datapath2,'\',int2str(i),'.jpg');
img = imread(str);
img = rgb2gray(img);
glcm2 = graycomatrix(img);
stats2 = graycoprops(glcm2);
live(i)=stats2.Homogeneity; %#ok<SAGROW>
end
output = live1(i)>= fake(i) & live1(i)<= fake(i);
if output<=0.9894
disp('The image is live ') % display
else
disp('The image is fake ') % display
end
  1 Comment
Rik
Rik on 20 May 2019
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!