从流线中提取特征点并将它们聚类?

时间:2015-09-08 08:08:58

标签: matlab tracking matlab-cvst opticalflow vision

我试图使用matlab制作一个可靠的乘客计数系统,相机将固定在门上方。我能够使用Lucas Kanade光流获得流线,线条代表人们的动作。我想:

  1. 从这些线中仅提取端点,如果线条足够长(线条矩阵包含所有点,甚至在地板的某个随机部分上指出一个点不会发生变化)
  2. 聚集这些优点'并获得代表人们的clustsers的质心
  3. 在这些群集中心上创建固定大小的边界框,并将它们发送到多个对象KLT跟踪程序。
  4. 有人会碰巧向我展示一个从行矩阵中提取我想要的点的好方法吗?我的matlab语法非常糟糕,我没有时间完成这项工作,它是一个单项目。提前谢谢!

    %example
        videoReader = vision.VideoFileReader('5Converted.avi','ImageColorSpace','Intensity','VideoOutputDataType','uint8');
        converter = vision.ImageDataTypeConverter; 
        opticalFlow = vision.OpticalFlow('ReferenceFrameDelay', 1);
        opticalFlow.OutputValue = 'Horizontal and vertical components in complex form';
        shapeInserter = vision.ShapeInserter('Shape','Lines','BorderColor','Custom', 'CustomBorderColor', 255);
        videoPlayer = vision.VideoPlayer('Name','Motion Vector');
        while ~isDone(videoReader)
            frame = step(videoReader);
            im = step(converter, frame);
            of = step(opticalFlow, im);
            [lines, trackedPoints] = getFlowLines(of, 20);
            if ~isempty(lines)   
              out =  step(shapeInserter, im, lines);   
            end
        end
        release(videoPlayer);
        release(videoReader);
    

    这是GetFLowLines函数(示例的略微修改版本):

    > function [vel_Lines, allTrackedPoints] = getFlowLines(vel_Values,
    > scaleFactor)  %Modified function based on Matlab's
    > 'videooptflowlines.m' helper function 
    > 
    > persistent first_time; persistent X; persistent Y; persistent RV;
    > persistent CV; if isempty(first_time)
    >     first_time     = 1;
    >     %% user may change the following three parameters
    >     borderOffset   = 5;
    >     decimFactorRow = 5;
    >     decimFactorCol = 5;    
    >     %%
    >     [R C] = size(vel_Values);
    >     RV = borderOffset:decimFactorRow:(R-borderOffset);   
    >     CV = borderOffset:decimFactorCol:(C-borderOffset);
    >     [Y X] = meshgrid(CV,RV); end
    > 
    > tmp = vel_Values(RV,CV); tmp = tmp.*scaleFactor; vel_Lines = [Y(:)  
    > X(:)   Y(:)+real(tmp(:))   X(:)+imag(tmp(:))]; allTrackedPoints =
    > [Y(:)+real(tmp(:))   X(:)+imag(tmp(:))];
    

0 个答案:

没有答案