码迷,mamicode.com
首页 > 其他好文 > 详细

【视频识别】基于matlab高斯模型视频车辆检测【含Matlab源码 503期】

时间:2021-06-28 20:32:07      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:with   create   pre   csdn   water   code   视频   logic   pix   

一、简介

技术图片
技术图片

二、源代码


frameRate = get(trafficObj,‘FrameRate‘);
% video = read(trafficObj);
% implay(video, frameRate);
darkCarValue = 50;
darkCar = rgb2gray(read(trafficObj,71));
noDarkCar = imextendedmax(darkCar, darkCarValue);
imshow(darkCar)
figure, imshow(noDarkCar)

sedisk = strel(‘disk‘,2);
noSmallStructures = imopen(noDarkCar, sedisk);
imshow(noSmallStructures)



nframes = get(trafficObj, ‘NumberOfFrames‘);
I = read(trafficObj, 1);
taggedCars = zeros([size(I,1) size(I,2) 3 nframes], class(I));

for k = 1 : nframes
    singleFrame = read(trafficObj, k);

    % Convert to grayscale to do morphological processing.
    I = rgb2gray(singleFrame);

    % Remove dark cars.
    noDarkCars = imextendedmax(I, darkCarValue);

    % Remove lane markings and other non-disk shaped structures.
    noSmallStructures = imopen(noDarkCars, sedisk);

    % Remove small structures.
    noSmallStructures = bwareaopen(noSmallStructures, 150);

    % Get the area and centroid of each remaining object in the frame. The
    % object with the largest area is the light-colored car.  Create a copy
    % of the original frame and tag the car by changing the centroid pixel
    % value to red.
    L = bwlabel(noSmallStructures);
    taggedCars(:,:,:,k) = singleFrame;
    if any(L(:))

三、运行结果

技术图片
技术图片

四、备注

版本:2014a
完整代码或代写加1564658423

【视频识别】基于matlab高斯模型视频车辆检测【含Matlab源码 503期】

标签:with   create   pre   csdn   water   code   视频   logic   pix   

原文地址:https://www.cnblogs.com/homeofmatlab/p/14942716.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!