• PUDN用户
    了解作者
  • matlab
    开发工具
  • 3KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 49
    下载次数
  • 2010-04-12 23:34
    上传日期
遗弃物品检测,通过摄像头实时获取外界景物来检测,比如车站,办公室等
videoabandonedobj.rar
  • videoabandonedobj.m
    7.5KB
内容介绍
%% Abandoned Object Detection % This demo tracks objects at a train station and determines which ones % remain stationary. Abandoned objects in public areas concern authorities % since they might pose a security risk. Algorithms, such as the one used % in this demo, can be used to assist security officers monitoring live % surveillance video by directing their attention to a potential area of % interest. % Copyright 2004-2009 The MathWorks, Inc. % $Revision: 1.1.6.1.2.1 $ $Date: 2009/12/17 14:01:07 $ %% Introduction % This demo illustrates how to use the BlobAnalysis System object to identify % objects and track them. The demo implements this algorithm using the % following steps: % % * Eliminate video areas that are unlikely to contain abandoned objects % by extracting a region of interest (ROI). % * Perform video segmentation using background subtraction. % * Calculate object statistics using the BlobAnalysis System object. % * Track objects based on their area and centroid statistics. % * Visualize the results. %% % Check whether the required video file needs to be downloaded from the % MathWorks(TM) website. clear;clc; status = videogetdemodata('viptrain.avi'); if ~status displayEndOfDemoMessage(mfilename); return; end %% Initialization % Use these next sections of code to initialize the required variables and % System objects. % % Rectangular ROI [Row coordinate of top-left corner, column coordinate of % top-left corner, height, width] roi = [80 100 240 360]; % Maximum number of objects to track maxNumObj = 200; % Number of frames that an object must remain stationary before an alarm is % raised alarmCount = 45; % Maximum number of frames that an abandoned object can be hidden before it % is no longer tracked maxConsecutiveMiss = 4; % Maximum allowable change in object area in percent areaChangeFraction = 15; % Maximum allowable change in object centroid in percent centroidChangeFraction = 20; % Minimum ratio between the number of frames in which an object is detected % and the total number of frames, for that object to be tracked. minPersistenceRatio = 0.7; % Offsets for drawing bounding boxes in original input video PtsOffset = int32(repmat([roi(1); roi(2); 0 ; 0],[1 maxNumObj])); %% % Create a MultimediaFileReader System object to read video from a file. hVideoSrc = video.MultimediaFileReader; hVideoSrc.Filename = 'viptraffic.avi'; hVideoSrc.VideoOutputDataType = 'single'; %% % Create a ColorSpaceConverter System object to convert the RGB image to % Y'CbCr format. hColorConv = video.ColorSpaceConverter; hColorConv.Conversion = 'RGB to YCbCr'; %% % Create an Autothresholder System object to convert an intensity image to a binary % image. hAutothreshold = video.Autothresholder; hAutothreshold.ThresholdScaleFactor = 1.3; %% % Create a MorphologicalClose System object to fill in small gaps in the detected objects. hClosing = video.MorphologicalClose; hClosing.Neighborhood = strel('square',5); %% % Create a BlobAnalysis System object to find the area, centroid, and bounding % box of the objects in the video. hBlob = video.BlobAnalysis; hBlob.MaximumCount = maxNumObj; hBlob.NumBlobsOutputPort = true; hBlob.MinimumBlobAreaSource = 'Property'; hBlob.MinimumBlobArea = 100; hBlob.MaximumBlobAreaSource = 'Property'; hBlob.MaximumBlobArea = 2500; hBlob.ExcludeBorderBlobs = true; %% % Create a ShapeInserter System object to draw rectangles around the abandoned % objects. hDrawRectangles1 = video.ShapeInserter; hDrawRectangles1.Fill = true; hDrawRectangles1.FillColor = 'Custom'; hDrawRectangles1.CustomFillColor = [1 0 0]; hDrawRectangles1.Opacity = 0.5; %% % Create an TextInserter System object to display the number of objects in the % video. hDisplayCount = video.TextInserter; hDisplayCount.Text = '%4d'; hDisplayCount.Color = [1 1 1]; hDisplayCount.Font = 'LucidaTypewriterRegular'; %% % Create a VideoPlayer System object to display the video with the abandoned % objects highlighted. hAbandonedObjects = video.VideoPlayer; hAbandonedObjects.WindowCaption = 'Abandoned Objects'; hAbandonedObjects.WindowPosition = [10 300 roi(4)+25 roi(3)+25]; %% % Create a ShapeInserter System object to draw rectangles around all the detected % objects in the video. hDrawRectangles2 = video.ShapeInserter; hDrawRectangles2.BorderColor = 'Custom'; hDrawRectangles2.CustomBorderColor = [0 1 0]; %% % Create a ShapeInserter System object to draw a rectangle around the region of % interest. hDrawBBox = video.ShapeInserter; hDrawBBox.BorderColor = 'Custom'; hDrawBBox.CustomBorderColor = [1 1 0]; %% % Create a VideoPlayer System object to display the video with all the % identified objects highlighted. hAllObjects = video.VideoPlayer; hAllObjects.WindowPosition = [45+roi(4) 300 roi(4)+25 roi(3)+25]; hAllObjects.WindowCaption = 'All Objects'; %% % Create a ShapeInserter System object to draw rectangles around all the % identified objects in the segmented video. hDrawRectangles3 = video.ShapeInserter; hDrawRectangles3.BorderColor = 'Custom'; hDrawRectangles3.CustomBorderColor = [0 1 0]; %% % Create a VideoPlayer System object to display the segmented video. hThresholdDisplay = video.VideoPlayer; hThresholdDisplay.WindowPosition = ... [80+2*roi(4) 300 roi(4)-roi(2)+25 roi(3)-roi(1)+25]; hThresholdDisplay.WindowCaption = 'Threshold'; %% Stream processing loop % Create a processing loop to perform abandoned object detection on the input % video. This loop uses the System objects you instantiated above. firsttime = true; while ~isDone(hVideoSrc) Im = step(hVideoSrc); % Select the region of interest from the original video OutIm = Im(roi(1):end, roi(2):end, :); YCbCr = step(hColorConv, OutIm); CbCr = complex(YCbCr(:,:,2), YCbCr(:,:,3)); % Store the first video frame as the background if firsttime firsttime = false; BkgY = YCbCr(:,:,1); BkgCbCr = CbCr; end SegY = step(hAutothreshold, abs(YCbCr(:,:,1)-BkgY)); SegCbCr = abs(CbCr-BkgCbCr) > 0.05; % Fill in small gaps in the detected objects Segmented = step(hClosing, SegY | SegCbCr); % Perform blob analysis [Area, Centroid, BBox, Count] = step(hBlob, Segmented); % Call the helper function that tracks the identified objects and % returns the bounding boxes and the number of the abandoned objects. [OutCount, OutBBox] = videoobjtracker(Area, Centroid, BBox, Count,... areaChangeFraction, centroidChangeFraction, maxConsecutiveMiss, ... minPersistenceRatio, alarmCount); % Display the abandoned object detection results Imr = step(hDrawRectangles1, Im, OutBBox+PtsOffset); Imr(1:15,1:30,:) = 0; Imr = step(hDisplayCount, Imr, OutCount); step(hAbandonedObjects, Imr); % Display all the detected objects Imr = step(hDrawRectangles2, Im, BBox+PtsOffset); Imr(1:15,1:30,:) = 0; Imr = step(hDisplayCount, Imr, OutCount); Imr = step(hDrawBBox, Imr, roi); step(hAllObjects, Imr); % Display the segmented video SegIm = step(hDrawRectangles3, repmat(Segmented,[1 1 3]), BBox); step(hThresholdDisplay, SegIm); end %% Close % Here you call the close method on the System objects to close any open files % and devices. close(hVideoSrc); %% Summary % In the Abandoned Objects window, you can see that the demo detected the % abandoned object located on the bench. It marks the location of this % object with a red rectangle. %% Appendix % The following helper function is used in this demo. % % * <matlab:edit('videoobjtracker.m') videoobjtracker.m> displayEndOfDemoMessage(mfilename)
评论
    相关推荐
    • videoabandonedobj.rar
      遗弃物品检测,通过摄像头实时获取外界景物来检测,比如车站,办公室等
    • videoabandonedobj.rar
      遗弃物品检测,通过摄像头实时获取外界景物来检测,比如车站,办公室等
    • codesforimageprocessing.rar
      实现简单图像处理,包括256色转灰度图、Hough变换、Walsh变换、中值滤波、二值化变换、亮度增减、傅立叶变换、反色、取对数、取指数、图像平移、图像旋转、图像细化、图像缩放、图像镜像、均值滤波、对比度拉伸、拉普拉斯锐化(边缘检测)、方块编码、梯度锐化、灰度均衡、直方图均衡、离散余弦变换、维纳滤波处理、逆滤波处理、阈值变换、高斯平滑。
    • matlab.rar
      基于MATLAB-GUI图形界面的数字图像处理软件 本系统设计基于GUI图形界面,用matlab语言编写代码,实现功能包括图象的读取、存储、显示、直方图均衡化、阈值化、小波分解、小波重构、加噪、去噪、平滑、锐化、边缘检测、图像分割等
    • OPENCV_SIFT_VC6.rar
      基于OPENCV的SIFT特征提取与匹配算法。包含完整的从图像高斯金字塔、DOG、空间极值点提取、关键点描述、KDtree匹配等关键步骤的全部函数实现,对全面深入理解Lowe的SIFT算法有莫大帮助。程序运行前须安装(1)OpenCV: http://opencvlibrary.sourceforge.net (2)SIFT: http://web.engr.oregonstate.edu/~hess/index.html,并配置其环境参数。
    • MATLAB_code_of_image_processing.rar
      该gui函数基本上包括图像处理里面的最基本处理,相当于一个小型photoshop。比如读取文件,几何变换中的垂直镜像,平移,旋转,缩放;正交变换的DFT,FFT,DCT,DST,DHT,DWashT;灰度处理中的反色,直方图均衡,全局线性变换,分段线性变换,指数非线性变换,对数非线性变换;图像增强里面的加噪声,平滑,锐化,伪彩色增强;图像分割里面的灰度阈值法,Robert,Laplace,sobel,prewitt,canny算子边缘检测法;图像恢复里面的直接逆滤波,维纳滤波;图像编码里面的霍夫曼编码,行程编码等等
    • bianyuan_jiance_bijiao.rar
      用六种算子(分别是gabor、拉普拉斯、priwitt、robert、sobel、wallis),对三种图象进行边缘检测比较,强烈推荐哦,是本人的毕业设计中的关键程序
    • 一维和二维小波变换的VC实现.rar
      小波算法在vc的具体实现.小波算法在图像处理,视频压缩,特征提取等领域有广泛应用,程序以灰度图像为数据分别演示了一维和二维小波变换,希望对大家有所帮助.谢谢!
    • thresold.rar
      基于小波变换阈值去噪的MATLAB源代码(包含小波包去噪程序)
    • HOG.rar
      基于HOG的行人检测,作者的源代码有错误,现代码已经进行了改变,并可以调试通