日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人工智能 > 循环神经网络 >内容正文

循环神经网络

光流法的视频移动目标检测(matlab代码)

發(fā)布時(shí)間:2023/12/16 循环神经网络 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 光流法的视频移动目标检测(matlab代码) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

光流法的視頻移動(dòng)目標(biāo)檢測(cè)
基于光流法采用matlab 的computer vision system toolbox實(shí)現(xiàn)對(duì)視頻中移動(dòng)目標(biāo)的檢測(cè)

clc; clear all; close all; videofile = 'viptraffic.avi'; info = mmfileinfo(videofile); cols=info.Video.Width; rows=info.Video.Height; hReader = vision.VideoFileReader(videofile,...'ImageColorSpace', 'RGB',... 'VideoOutputDataType', 'single'); hFlow = vision.OpticalFlow( ...'OutputValue', 'Horizontal and vertical components in complex form', ...'ReferenceFrameDelay', 3,...'Method','Horn-Schunck'); hMean1 = vision.Mean; hMean2 = vision.Mean('RunningMean', true); hFilter = vision.MedianFilter; hClose = vision.MorphologicalClose('Neighborhood', strel('line',5,45)); hBlob = vision.BlobAnalysis(...'CentroidOutputPort', false,...'AreaOutputPort', true, ...'BoundingBoxOutputPort', true,...'OutputDataType', 'double', ...'MinimumBlobArea', 250,...'MaximumBlobArea', 3600,...'MaximumCount', 80); hErode = vision.MorphologicalErode('Neighborhood', strel('square',2)); hShape1 = vision.ShapeInserter(...'BorderColor', 'Custom', ...'CustomBorderColor', [0 1 0]); hShape2 = vision.ShapeInserter(...'Shape','Lines', ...'BorderColor', 'Custom', ...'CustomBorderColor', [255 255 0]); hText = vision.TextInserter(...'Text', '%4d',...'Location', [1 1], ...'Color', [1 1 1],...'FontSize', 12); sz = get(0,'ScreenSize'); pos = [(sz(3)-4*(cols+75))/2, (sz(4)-rows)/2 cols+60 rows+80]; hVideo1 = vision.VideoPlayer('Name','Original Video','Position',pos); pos(1) = pos(1)+cols+75; hVideo2 = vision.VideoPlayer('Name','Motion Vector','Position',pos); pos(1) = pos(1)+cols+75; hVideo3 = vision.VideoPlayer('Name','Thresholded Video','Position',pos); pos(1) = pos(1)+cols+75; hVideo4 = vision.VideoPlayer('Name','Results Video','Position',pos); [xpos,ypos]=meshgrid(1:5:cols,1:5:rows); xpos=xpos(:); ypos=ypos(:); locs=sub2ind([rows,cols],ypos,xpos); while ~isDone(hReader)pause(0.3);frame = step(hReader);gray = rgb2gray(frame);flow = step(hFlow, gray);lines = [xpos, ypos, xpos+20*real(flow(locs)), ypos+20*imag(flow(locs))];vector = step(hShape2, frame, lines);magnitude = flow .* conj(flow);threshold = 0.5 * step(hMean2, step(hMean1, magnitude));carobj = step(hFilter, magnitude >= threshold);carobj = step(hClose, step(hErode, carobj));[area, bbox] = step(hBlob, carobj);grow=22;idx = bbox(:,1) > grow;ratio = zeros(length(idx), 1);ratio(idx) = single(area(idx,1))./single(bbox(idx,3).*bbox(idx,4));flag = ratio > 0.4;count = int32(sum(flag));bbox(~flag, :) = int32(-1);result = step(hShape1, frame, bbox);result(grow:grow+1,:,:) = 1;result(1:15,1:30,:) = 0;result = step(hText, result, count);step(hVideo1, frame); step(hVideo2, vector); step(hVideo3, carobj); step(hVideo4, result); end release(hReader);

結(jié)果:

總結(jié)

以上是生活随笔為你收集整理的光流法的视频移动目标检测(matlab代码)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。