Saturday, January 24, 2015

How To Train your cascade classifier using Matlab...


Training isn't that easy when the subject is complicated, but good teachers deliver it efficiently, just like how Matlab does the thing here..

How does it work.... ?

So Let's start with an existing cascade classifier file and see how it works. 'Frontal Face Detector ' is the one available (and is the default in Matlab) in net.  Check out the video to see how it does its job.

(Don't take it seriously, I am having my breakfast)
And here is the code behind the above video.


%% 
% read a video file ,process it and save the 
% modified video file
%%
gun_det=vision.CascadeObjectDetector();
vid_reader=vision.VideoFileReader('raj_blog.avi');
vid_writer=VideoWriter('raj_blog_mdfd_1.avi');
open(vid_writer);
 while ~isDone(vid_reader)

     frame=step(vid_reader);
     bbox=step(gun_det,frame);
     frame=insertObjectAnnotation(frame,'rectangle',bbox,'Face');
     writeVideo(vid_writer,frame);
     
 end
 close(vid_writer);
 release(vid_reader);
% see the o/p video file in your directory

Lets get started soon....