Sunday, 14 April 2013

People Counting System using face detection Code

close all;
clear all;
rgbInputImage = imread('photo.jpg');
labInputImage = applycform(rgbInputImage,makecform('srgb2lab'));
Lbpdfhe = fcnBPDFHE(labInputImage(:,:,1));
labOutputImage = cat(3,Lbpdfhe,labInputImage(:,:,2),labInputImage(:,:,3));
rgbOutputImage = applycform(labOutputImage,makecform('lab2srgb'));
figure, imshow(rgbInputImage);
figure, imshow(rgbOutputImage);
final_image = zeros(size(img,1), size(img,2));
if(size(img, 3) > 1)
for i = 1:size(img,1)
for j = 1:size(img,2)
R = img(i,j,1);
G = img(i,j,2);
B = img(i,j,3);
if(R > 92 && G > 40 && B > 20)
v = [R,G,B];
if((max(v) - min(v)) > 15)
if(abs(R-G) > 15 && R > G && R > B)
final_image(i,j) = 1;
figure, imshow(binaryImage);
binaryImage = imfill(binaryImage, 'holes');
figure, imshow(binaryImage);
binaryImage = bwareaopen(binaryImage,1890);
labeledImage = bwlabel(binaryImage, 8);
blobMeasurements = regionprops(labeledImage, final_image, 'all');
numberOfPeople = size(blobMeasurements, 1)
imagesc(rgbInputImage); title('Outlines, from bwboundaries()');
hold on;
boundaries = bwboundaries(binaryImage);
for k = 1 : numberOfPeople
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
hold on;
title('Original with bounding boxes');
for k = 1 : numberOfPeople
thisBlobsBox = blobMeasurements(k).BoundingBox;
x1 = thisBlobsBox(1);
y1 = thisBlobsBox(2);
x2 = x1 + thisBlobsBox(3);
y2 = y1 + thisBlobsBox(4);
x = [x1 x2 x2 x1 x1];
y = [y1 y1 y2 y2 y1];
plot(x, y, 'LineWidth', 2);

fcnBPDFHE() function should be added

avialable in mathworks website link is here :

Used image URL : 

Sunday, 7 April 2013

Silent Password Creation using matlab

Here we are going to create silent password.We can do this using both from a video file or from live streaming.The main thing is that he camera should focus on the lip.It should track the lip movement.The key idea is that we are going to take a threshold value,using that particular value we are going to check whether the password is wrong or right.We will track the lip movement,if the movement is beyond threshold then wrong password otherwise right.

Well here are the steps we need to do to create a silent password with matlab :

1.Take video of lip movement or record using webcam.

2.Now use a detection algorithm algorithm from here
(Note : if you are using live detection you need to track the motion using another method,that code is also available in this blog,here is the link.

3.Now what you need to do is that you need to set the threshold value.

Threshold value :

Now the threshold value can be set or generated in many ways.I have done it in one way what i am going to tell you but you can follow different approach. 

i.I have calculated the no of frames between one lip touching frame to the next one.In live streaming case the threshold should be given a bit large for less errors.

ii..For my case the calculated frame no is the threshold.If you find any better approach please let me know through comment.

4.So once the threshold is calculated your prog is okk.

5.Now simple calculation if detected result is beyond threshold then rejected otherwise accepted.