使用MATLAB机器视觉工具箱实现人脸的检测和跟踪
2015-04-28 10:27
531 查看
跟图像处理、机器人视觉相关的MATLAB工具箱有:
Image Processing Toolbox (图像处理工具箱)
Computer Vision System Toolbox (计算机视觉工具箱)
Image Acquisition Toolbox (图像采集工具箱)
一般情况下,一个完整的机器人视觉应用需要用到这三个工具箱(我会近期开发一个使用MATLAB实现的家庭安全检测系统,可以详细讲解一下整个流程)
第一步:检测人脸
第二步:从检测到的人脸里提取重要的特征,用于第三步的人脸追踪使用
第三步:人脸追踪
怎样将测试视频换成从摄像头读入,解释如下,具体可看原文评论:点击打开链接
你要是有新版matlab (好像2014b之后),可以用webcam function
http://www.mathworks.com/help/su ... cams/ug/webcam.html
或者看image acquisition toolbox里面的example
http://www.mathworks.com/products/imaq/code-examples.html
Image Processing Toolbox (图像处理工具箱)
Computer Vision System Toolbox (计算机视觉工具箱)
Image Acquisition Toolbox (图像采集工具箱)
一般情况下,一个完整的机器人视觉应用需要用到这三个工具箱(我会近期开发一个使用MATLAB实现的家庭安全检测系统,可以详细讲解一下整个流程)
第一步:检测人脸
<span style="font-size:14px;">% Create a cascade detector object. faceDetector = vision.CascadeObjectDetector(); % Read a video frame and run the detector. videoFileReader = vision.VideoFileReader('visionface.avi'); videoFrame = step(videoFileReader); bbox = step(faceDetector, videoFrame); % Draw the returned bounding box around the detected face. boxInserter = vision.ShapeInserter('BorderColor','Custom',... 'CustomBorderColor',[255 255 0]); videoOut = step(boxInserter, videoFrame,bbox); figure, imshow(videoOut), title('Detected face');</span>实际引用中,大家可以把读取的avi文件,换成摄像机实时数据的获取。
第二步:从检测到的人脸里提取重要的特征,用于第三步的人脸追踪使用
<span style="font-size:14px;">% Get the skin tone information by extracting the Hue from the video frame % converted to the HSV color space. [hueChannel,~,~] = rgb2hsv(videoFrame); % Display the Hue Channel data and draw the bounding box around the face. figure, imshow(hueChannel), title('Hue channel data'); rectangle('Position',bbox(1,:),'LineWidth',2,'EdgeColor',[1 1 0])</span>这里面,我们把rgb图像转换成HSV图像
第三步:人脸追踪
<span style="font-size:14px;">% Detect the nose within the face region. The nose provides a more accurate % measure of the skin tone because it does not contain any background % pixels. 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, noseBBox); % Create a video player object for displaying video frames. videoInfo = info(videoFileReader); videoPlayer = vision.VideoPlayer('Position',[300 300 videoInfo.VideoSize+30]); % Track the face over successive video frames until the video is finished. while ~isDone(videoFileReader) % Extract the next video frame videoFrame = step(videoFileReader); % 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); % Display the annotated video frame using the video player object step(videoPlayer, videoOut); end % Release resources release(videoFileReader); release(videoPlayer);</span>
怎样将测试视频换成从摄像头读入,解释如下,具体可看原文评论:点击打开链接
你要是有新版matlab (好像2014b之后),可以用webcam function
http://www.mathworks.com/help/su ... cams/ug/webcam.html
或者看image acquisition toolbox里面的example
http://www.mathworks.com/products/imaq/code-examples.html
相关文章推荐
- 声卡虚拟示波器简单功能-使用matlab DAQ工具箱中API实现
- 基于肤色和眼睛定位的人脸检测算法——MATLAB实现【转】
- 毕业设计——人脸检测——002 MATLAB实现提取一张图片像素点的RGB值
- PCA检测人脸的简单示例_matlab实现
- opencv下haar方法实现对视频文件的人脸检测、跟踪
- PCA检测人脸的简单示例_matlab实现
- 基于肤色和眼睛定位的人脸检测算法——MATLAB实现
- OpenCV与Compressive Tracking实现人脸的实时检测与跟踪
- MATLAB实现多分类和libsvm工具箱的安装使用详解
- matlab使用FULLBNT工具箱实现贝叶斯网络
- 基于MATLAB的adaboost级联形式的人脸检测实现
- 【模式识别】PCA检测人脸的简单示例MATLAB实现
- PCA检测人脸的简单示例_matlab实现
- PCA检测人脸的简单示例_matlab实现
- python结合opencv实现人脸检测与跟踪
- python结合opencv实现人脸检测与跟踪
- 关于Android 使用官方API 实现人脸检测功能
- OpenCV与Compressive Tracking实现人脸的实时检测与跟踪
- 使用MATLAB + psychtoolbox 实现的钟表 可以检测反映速度哦
- 基于MATLAB的adaboost级联形式的人脸检测实现