Search This Blog

Monday, May 30, 2016

Finally: a working raspberry pi /matlab connection. Test: face Detection

Here is a demo of my working raspberry pi connected to my computer over the network.
For OS X users having problems installing the raspberry pi support package. Dont forget running matlab as an administrator before starting the installation.
Face Detection was the easiest way to test both the pi and the cam module.
Below you can find the matlab code for face detection with raspberry bei and you can also use any different cam bei slightly modifying the code.

clear rpi
rpi = raspi();
cam = cameraboard(rpi, 'Resolution', '640x480');

for i = 1:20
a = snapshot(cam);

% here i had to rotate the image becasue the way my pi is positioned 

%Create a detector object.
faceDetector = vision.CascadeObjectDetector;

% Detect faces.
bboxes = step(faceDetector, img);

% Annotate detected faces.
IFaces = insertObjectAnnotation(img, 'rectangle', bboxes, 'Face');
figure, imshow(IFaces), title('Detected faces');