matlab codes for face detection from a web cam video

please TELL me the MATLAB Code to detect or track a face in a real time video using A webcam in MATLAB* I AM DOING MY PROJECT IN FACE RECOGNITION, BUT NOT GETTING HELP FROM ANYWHERE. Thank you....

5 件のコメント

Image Analyst
Image Analyst 2014 年 2 月 4 日
Face detection (any face at all) is different than face recognition (that's your face because it matches my database best). Face detection is in the Computer Vision System Toolbox.
Githinji charles
Githinji charles 2014 年 2 月 7 日
ry this code and try to change .For any adverncement contact me through charmagithi@gmail.com 0r send me a letter 90420 .MOMBASA KENYA function [ ] = facetracker( ); %Create a cascadeObjectDetector, by default it detects the face faceDetector = vision.CascadeObjectDetector();
%Get the input device using image acquisition toolbox,resolution = 640x480 to improve performance vid =imaq.VideoDevice('linuxvideo', 1, 'YUYV_320x240', 'ROI', [1 1 320 240], ... 'ReturnedColorSpace', 'rgb', ... 'DeviceProperties.Brightness', 64, ... 'DeviceProperties.Sharpness', 64);%vid=videoinput('linuxvideo',1,'YUYV_160X120');
set( vid.DeviceProperties,'Brightness', 64); optical = vision.OpticalFlow( ... 'OutputValue', 'Horizontal and vertical components in complex form');
maxWidth = imaqhwinfo(vid,'MaxWidth'); maxHeight = imaqhwinfo(vid,'MaxHeight'); shapes = vision.ShapeInserter; shapes.Shape = 'Lines'; shapes.BorderColor = 'white'; r = 1:5:maxHeight; c = 1:5:maxWidth; [Y, X] = meshgrid(c,r);
Video = 'Motion Detected Video'; nFrames = 0; while (nFrames<100) % Process for the first 100 frames. % Acquire single frame from imaging device. rgbData = step(vid); videoFrame=(rgbData ); %step(hVideoOut,rgbData); pause(2) %Get a bounding box around the face bbox = step(faceDetector, videoFrame); boxInserter = vision.ShapeInserter('BorderColor','Custom',... 'CustomBorderColor',[255 255 0]); videoOut = step(boxInserter, videoFrame,bbox);
figure, imshow(videoOut), title('Detected face'); [hueChannel,~,~] = rgb2hsv(videoFrame);
% Display the Hue Channel data and draw the bounding box around the face. figure, imshow(hueChannel), title('Hue channel data'); hold on rectangle('Position',bbox,'EdgeColor','r','LineWidth',1) hold off noseDetector = vision.CascadeObjectDetector('Nose'); faceImage = imcrop(videoFrame,bbox); noseBBox = step(noseDetector,faceImage);
% The nose bounding box is defined relative to the cropped face image. % Adjust the nose bounding box so that it is relative to the original video % frame. noseBBox(1:2) = noseBBox(1:2) + bbox(1:2); % Create a tracker object. tracker = vision.HistogramBasedTracker; % Initialize the tracker histogram using the Hue channel pixels from the % nose. initializeObject(tracker, hueChannel, bbox); %Check if something was detected, otherwise exit % Create a video player object for displaying video frames. videoInfo = info(vid); ROI=get(vid,'ROI'); VideoSize = [ROI(3) ROI(4)]; videoPlayer = vision.VideoPlayer('Position',[300 300 VideoSize+30]);
while (1)
% Extract the next video frame videoFrame = step(vid); % RGB -> HSV [hueChannel,~,~] = rgb2hsv(videoFrame);
% Track using the Hue channel data
bbox = step(tracker, hueChannel);
% Insert a bounding box around the object being tracked
videoOut = step(boxInserter, videoFrame, bbox);
%Insert text coordinates
% Display the annotated video frame using the video player object
step(videoPlayer, videoOut);
end
% Release resources release(vid); release(videoPlayer);
chandu kotipalli
chandu kotipalli 2017 年 2 月 20 日
the above code is not working
Jan
Jan 2017 年 2 月 20 日
@chandu: The above code is not formatted correctly. Then after a copy&paste the block of text does not have valid Matlab syntax.

サインインしてコメントする。

 採用された回答

Shivaputra Narke
Shivaputra Narke 2014 年 2 月 3 日

0 投票

Its not a small code. The better way is, you just go through different steps.
1.First understand how to use webcam in matlab. 2.Get frames from video. 3.Perform Segmentation 4.Then use any face detection algorithm. Perform steps 2 to 4 continuously.

4 件のコメント

sanjida
sanjida 2014 年 2 月 4 日
thanks. can i do these steps with matlab2010a????????
Walter Roberson
Walter Roberson 2014 年 2 月 4 日
Yes. However, my recollection is that some of the most useful tools in Computer Vision Toolbox were not available that early.
Donal Wambou nono
Donal Wambou nono 2022 年 4 月 2 日
how can we do to have it ?
Walter Roberson
Walter Roberson 2022 年 4 月 3 日
Which MATLAB release are you using? And could you restate what it is that you need to do?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by