资源简介
通过KLT Algorithm可以实现对视频中人脸的定位与追踪,效果良好
代码片段和文件信息
%% Face Detection and Tracking Using the KLT Algorithm
% This example shows how to automatically detect and track a face using
% feature points. The approach in this example keeps track of the face even
% when the person tilts his or her head or moves toward or away from the
% camera.
%
% Copyright 2013 The MathWorks Inc.
%% Detect a Face
% Create a cascade detector object.
faceDetector = vision.CascadeobjectDetector();
% Open a video file
videoFileReader = vision.VideoFileReader(‘tilted_face.avi‘);
% Read a video frame and run the face detector.
videoframe = step(videoFileReader);
bbox = step(faceDetector videoframe);
% Convert the box to a polygon. This is needed to be able to visualize the
% rotation of the object.
x = bbox(1); y = bbox(2); w = bbox(3); h = bbox(4);
bboxPolygon = [x y x+w y x+w y+h x y+h];
% Draw the returned bounding box around the detected face.
shapeInserter = vision.ShapeInserter(‘Shape‘ ‘Polygons‘ ‘BorderColor‘‘Custom‘...
‘CustomBorderColor‘[255 255 0]);
videoframe = step(shapeInserter videoframe bboxPolygon);
figure; imshow(videoframe); title(‘Detected face‘);
%% Identify Facial Features To Track
% Crop out the region of the image containing the face and detect the
% feature points inside it.
cornerDetector = vision.CornerDetector(‘Method‘ ...
‘Minimum eigenvalue (Shi & Tomasi)‘);
points = step(cornerDetector rgb2gray(imcrop(videoframe bbox)));
% The coordinates of the feature points are with respect to the cropped
% region. They need to be translated back into the original image
% coordinate system.
points = double(points);
points(: 1) = points(: 1) + double(bbox(1));
points(: 2) = points(: 2) + double(bbox(2));
% Display the detected points.
markerInserter = vision.MarkerInserter(‘Shape‘ ‘Plus‘ ...
‘BorderColor‘ ‘White‘);
videoframe = step(markerInserter videoframe points);
figure imshow(videoframe) title(‘Detected features‘);
%% Initialize a Tracker to Track the Points
% Create a point tracker and enable the bidirectional error constraint to
% make it more robust in the presence of noise and clutter.
pointTracker = vision.PointTracker(‘MaxBidirectionalError‘ 2);
% Initialize the tracker with the initial point locations and the initial
% vide
- 上一篇:UML网上购物系统 实体类图
- 下一篇:量子遗传算法matlab代码.zip
相关资源
- matlab开发-FlockingAlgorithm
- 烟花算法 (Fireworks Algorithm),缩写为
- 微机保护算法仿真.zip
- ISARImagingWithMATLABAlgorithms.rar
- ISAR Imaging With MATLAB Algorithms
- 遗传算法(Genetic Algorithm)MATLAB案例详
- Fusiello极线校正_A compact algorithm for r
- machine trading: deploying computer algorithms
- X S Yang firefly algorithm萤火虫所有算法文
- CURE algorithm
- 基于MATLAB的人脸动态追踪
- NETLAB algorithms for pattern recognition
- Synthetic Aperture Radar Signal Processing wit
- synthetic aperture radar signal processing wit
- Inverse Synthetic Aperture Radar Imaging with
- Synthetic Aperture Radar Signal Processing wit
- Robotics Vision and Control (Fundamental Alg
- matlab开发-Edmondsalgorithm
- easi algorithm for blind source separation
- 神经网络中hopfield算法的Matlab的实现
- KLT_MATLAB
- LMS和RLS算法
- KLTransform
- lm算法的matlab实现
- Chicken Swarm Optimization鸡群优化算法和
- 2014年最新提出的仿生群智能优化算法
-
matlab开发-mssamultiob
jectivesalpswarmalg - Connected Component algorithm
- The MATLAB Genetic Algorithm Toolbox
- SIMPLE算法Matlab代码
评论
共有 条评论