การตรวจจับใบหน้าอย่างง่าย - Simple face detection
MATLAB Simple Face Detection
การตรวจจับใบหน้าอย่างง่าย โดยใช้แม็ทแล็ป
การตรวจจับใบหน้า มักจะเป็นที่นิยมกันมากที่สุดในการหยิบยกมาเป็นตัวอย่าง สำหรับงาน impage processing ดังนั้น ในตัวอย่างนี้ เราจะมาดูกันว่าวิธีการเขียนโปรแกรมตรวจจับใบหน้านั้น มันเขียนกันยังไง พร้อมแล้วก็ไปดูกันเลยครับ
วีดีโอผลการรัน
โค้ดโปรแกรมทั้งหมด
การตรวจจับใบหน้าอย่างง่าย โดยใช้แม็ทแล็ป
การตรวจจับใบหน้า มักจะเป็นที่นิยมกันมากที่สุดในการหยิบยกมาเป็นตัวอย่าง สำหรับงาน impage processing ดังนั้น ในตัวอย่างนี้ เราจะมาดูกันว่าวิธีการเขียนโปรแกรมตรวจจับใบหน้านั้น มันเขียนกันยังไง พร้อมแล้วก็ไปดูกันเลยครับ
วีดีโอผลการรัน
โค้ดโปรแกรมทั้งหมด
clc;clear;close all; % Create a cascade detector object. faceDetector = vision.CascadeObjectDetector(); % Read a video frame and run the face detector. vidFile = 'D:\MATLAB JOB\Bloger-Loglike\Video\Test01.mp4'; videoFileReader = vision.VideoFileReader(vidFile); videoFrame = step(videoFileReader); videoFrame = imresize(videoFrame,0.5); bbox = step(faceDetector, videoFrame); % Draw the returned bounding box around the detected face. videoFrame = insertShape(videoFrame, 'Rectangle', bbox); figure('tag','vidPlayer'); G = imshow(videoFrame); title('Detected face'); skipt = 1; n = 0; while not(isDone(videoFileReader)) %check user close figure h = findobj('tag','vidPlayer'); if(isempty(h)) break; end %skip frame for fast show if(n<=skipt) n = n+1; frm = step(videoFileReader); continue; end n = 0; frm = step(videoFileReader); frm = imresize(frm,0.5); bbox = step(faceDetector, frm); nfrm = insertShape(frm, 'Rectangle', bbox); set(G,'CData',nfrm); pause(0.01); end close all;