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
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
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
2017년 2월 20일
the above code is not working
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.
채택된 답변
추가 답변 (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!