您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > 关于人脸检测的MATLAB代码
关于人脸检测的Matlab代码FACEDETECTION:clearallclc%DetectobjectsusingViola-JonesAlgorithm%TodetectFaceFDetect=vision.CascadeObjectDetector;%ReadtheinputimageI=imread('HarryPotter.jpg');%ReturnsBoundingBoxvaluesbasedonnumberofobjectsBB=step(FDetect,I);figure,imshow(I);holdonfori=1:size(BB,1)rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');endtitle('FaceDetection');holdoff;Thestep(Detector,I)returnsBoundingBoxvaluethatcontains[x,y,Height,Width]oftheobjectsofinterest.BB=52387373379847171198577272NOSEDETECTION:%TodetectNoseNoseDetect=vision.CascadeObjectDetector('Nose','MergeThreshold',16);BB=step(NoseDetect,I);figure,imshow(I);holdonfori=1:size(BB,1)rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','b');endtitle('NoseDetection');holdoff;MOUTHDETECTION:%TodetectMouthMouthDetect=vision.CascadeObjectDetector('Mouth','MergeThreshold',16);BB=step(MouthDetect,I);figure,imshow(I);holdonfori=1:size(BB,1)rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','r');endtitle('MouthDetection');holdoff;EYEDETECTION:%TodetectEyesEyeDetect=vision.CascadeObjectDetector('EyePairBig');%ReadtheinputImageI=imread('harry_potter.jpg');BB=step(EyeDetect,I);figure,imshow(I);rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');title('EyesDetection');Eyes=imcrop(I,BB);figure,imshow(Eyes);
本文标题:关于人脸检测的MATLAB代码
链接地址:https://www.777doc.com/doc-1390618 .html