博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【Matlab/CV系列】简单目标跟踪系统设计
阅读量:2041 次
发布时间:2019-04-28

本文共 3043 字,大约阅读时间需要 10 分钟。

Date: 2019-5-2


前言

    目标跟踪一直是计算机视觉领域中一个比较重要的研究课题,实际应用较多。本文主要采用背景差分法、帧差法和光流法实现简单的目标跟踪系统。

1、参考

2、Matlab实现(部分)
function d = tracking(video)pixels = video;nFrames = size(pixels, 4);rows = size(pixels, 1);cols = size(pixels, 2);% 转换成灰度图像for i = 1 : nFrames    pixel(:, :, i) = (rgb2gray(pixels(:,:,:,i)));endw_history = 0;for i = 2 : nFrames    d(:, :, i) = (abs(pixel(:,:,i) - pixel(:,:,i-1)));    bw(:, :, i) = im2bw(d(:, :, i), 0.2);    % 寻找上下边界    cou=1;    for h = 1:rows        for w = 1:cols            if bw(h, w, i) > 0.5                bottomEdge = h;                if cou == 1                    topEdge = bottomEdge;                end                cou = cou+1;                break;            end        end    end    % 寻找左右边界    coun=1;    for w = 1:cols        for h = 1:rows            if bw(h, w, i) > 0.5                if i <= 2/3*nFrames                    if abs(w-w_history) < 72.1                         rightEdge = w;                    else                        rightEdge = w_history+1;                    end                else                    if abs(w-w_history) < 62.5                         rightEdge = w;                    else                        rightEdge = w_history+1;                    end                end                if coun == 1                    leftEdge = rightEdge;                    coun = coun+1;                end                w_history = rightEdge;                break;            end        end    end    % 矩形框生成    wd = rightEdge-leftEdge;    hg = bottomEdge-topEdge;        widt = wd/2;    heit = hg/2;    cenx = leftEdge+widt;    ceny = topEdge+heit;    % 显示并标记    figure(1);    imshow(pixels(:, :, :, i), []);    hold on    rectangle('Position',[cenx-10 topEdge 20 hg], 'EdgeColor', 'r', 'LineWidth', 2);    plot(cenx, ceny, 'ko', 'MarkerFaceColor', 'r', 'MarkerSize', 10, 'LineWidth', 2);            text(1, 15, sprintf('跟踪视频:%d帧', i), 'FontWeight', 'Bold', 'Color', 'r');    hold offend
3、实验效果图
3.1、背景差分法实现目标跟踪

在这里插入图片描述

3.2、帧差法实现目标跟踪

在这里插入图片描述

3.3、光流法实现目标跟踪

在这里插入图片描述

在这里插入图片描述

4、更多知识
4.1、matlab GUI中imshow刷新问题

在matlab 2012b中GUI中显示视频是可以正常显示的,但是在更高版本的2014b中,在axes中不能刷新出视频中每帧数据,只能显示出来最后一帧。

解决方案:在imshow后面加上drawnow。

help drawnow

drawnow Flush pending graphics events.
drawnow “flushes the event queue” and updates the figure window.
drawnow causes figure windows and their children to update and
flushes the system event queue. Any callbacks generated by incoming
events - e.g. mouse or key events - will be dispatched before
drawnow returns.
drawnow(‘EXPOSE’) causes only graphics objects to refresh, if
needed. It does not allow callbacks to execute and does not
process other events in the queue.
drawnow(‘UPDATE’) causes only non-graphics objects to refresh, if
needed. It does not allow callbacks to execute and does not
process other events in the queue.
drawnow is called implicitly upon returning to the MATLAB prompt and
when executing the following functions:

figure

getframe
ginput
input
keyboard
pause
waitfor
waitforbuttonpress


作者:SoaringLee_fighting

来源:CSDN
原文:
版权声明:本文为博主原创文章,转载请附上博文链接!


THE END!

在这里插入图片描述

你可能感兴趣的文章
OpenSSL源代码学习[转]
查看>>
Spring下载地址
查看>>
wxzh001,进来看关于APACHE+PHP+MYSQL+SSL的LINUX下安装配置(转自奥索)
查看>>
google app api相关(商用)
查看>>
linux放音乐cd
查看>>
GridView+存储过程实现'真分页'
查看>>
flask_migrate
查看>>
解决activemq多消费者并发处理
查看>>
UDP连接和TCP连接的异同
查看>>
hibernate 时间段查询
查看>>
java操作cookie 实现两周内自动登录
查看>>
jstl 中获得session 里面值sessionScope
查看>>
Tomcat 7优化前及优化后的性能对比
查看>>
VisualVM 提示 tomcat 不受此jvm支持解决办法
查看>>
Java Guava中的函数式编程讲解
查看>>
Eclipse Memory Analyzer 使用技巧
查看>>
tomcat连接超时
查看>>
DNS 原理入门
查看>>
爬虫 IP代理策略
查看>>
大数据学习笔记1000条
查看>>