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 个评论

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.
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: The above code is not formatted correctly. Then after a copy&paste the block of text does not have valid Matlab syntax.

请先登录,再进行评论。

 采纳的回答

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 个评论

thanks. can i do these steps with matlab2010a????????
Yes. However, my recollection is that some of the most useful tools in Computer Vision Toolbox were not available that early.
Which MATLAB release are you using? And could you restate what it is that you need to do?

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Image 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