Face Detection Using MATLAB and RPi
Face Detection Using MATLAB and RPi
on Raspberry Pi 3
Step 2
& hit Enter. MATLAB will now run the support package installer &
populate a list of available support packages from MATLAB.
On the left hand pane, browse for Raspberry Pi & select it.
Once selected, available packages are shown on the right hand
Step 3
panel. Select the support package from MATLAB and install it.
This will proceed to download the Wheezy image for RPi along
with the required support files
Once downloaded, insert a freshly formatted microSD card with
Step 4
them over to MATLAB for processing OR use the video player to capture
video from the RPi camera & then process it in MATLAB.
Method 1: Continuous stream of images:
Create a new script file & type:
Step 1
mypi = raspi()
package.
mysnap = snapshot(mycam);
Step 3
Step 5
title(Detected Face);
Drawnow
Save this script with a required name & run the script on RPi over serial
connection.
Step 9
Full Code
clearvars
mypi = raspi();
mycam = cameraboard(mypi, 'Resolution', '640x480', 'Brightness', 65);
mysnap = snapshot(mycam);
flag = 1;
while flag
clearvars -except mypi mycam flag
mysnap = snapshot(mycam);
imshow(mysnap);
hold on
fD = vision.CascadeObjectDetector
bbox = step(fD, mysnap);
imageOut = insertObjectAnnotation(mysnap, 'rectangle', bbox, 'Face');
imshow(imageOut);
title('Detected face');
drawnow
end
step(myPlayer, mysnap);
Full Code:
mypi = raspi();
myCam = cameraboard(mypi,'Resolution','640x480');
mySnap = snapshot(myCam);
myPlayer = vision.VideoPlayer;
step(myPlayer,mySnap);
while isOpen(myPlayer)
clearvars -except mypi myCam myPlayer
mySnap = snapshot(myCam);
step(myPlayer,mySnap);
fD = vision.CascadeObjectDetector();
bbox = step(fD, mySnap);
imageOut = insertObjectAnnotation(mySnap,'rectangle',bbox,'Face');
step(myPlayer,imageOut);
end
Final Result: