I am using this code for detecting abandoned objects in a video sequence but in image subtraction module the code detects the object initially and then stops detecting it once it stays in for a couple of frames?

조회 수: 4 (최근 30일)
foregroundDetector = vision.ForegroundDetector('NumGaussians', 3,'NumTrainingFrames',400);
videoReader = vision.VideoFileReader('C:\Users\Mahim Alam Khan\Documents\MATLAB\GMM #1\AOB.mp4');
se = strel('octagon', 6);
for i = 1:400;
frame = step(videoReader);
foreground = step(foregroundDetector, frame);
end
filteredForeground = imclose(foreground, se);
filteredForeground = imopen(foreground, se);
blobAnalysis = vision.BlobAnalysis('BoundingBoxOutputPort', true,'AreaOutputPort', false, 'CentroidOutputPort', false,'MinimumBlobArea', 10);
% bbox = step(blobAnalysis, filteredForeground);
% result = insertShape(frame, 'Rectangle', bbox, 'Color', 'green');
videoPlayer=vision.DeployableVideoPlayer(10);
videoPlayer.Size='Custom';
videoPlayer.CustomSize=[650 400];
videoPlayer=vision.VideoPlayer('Position', [740, 200, 700, 400]);
videoPlayer1=vision.DeployableVideoPlayer(10);
videoPlayer1.Size='Custom';
videoPlayer1.CustomSize=[650 400];
videoPlayer1 = vision.VideoPlayer('Position', [20, 200, 700, 400]);
se = strel('octagon', 6);
while ~isDone(videoReader)
frame = step(videoReader);
foreground = step(foregroundDetector, frame);
filteredForeground = imopen(foreground, se);
bbox = step(blobAnalysis, filteredForeground);
result = insertShape(frame, 'Rectangle', bbox, 'Color', 'green');
step(videoPlayer, result);
step(videoPlayer1, filteredForeground);
end
release(videoReader);

답변 (2개)

Sammit Jain
Sammit Jain 2017년 12월 27일
I think this is happening possibly because the image subtraction method you're using constantly updates the background too, which is why a moving object is detected, and not stationery ones (because a stationery one becomes a part of the scene in a later frame).
See if you can fix the background frame (that is, not update it) and it should work just fine.
All the best!
  댓글 수: 1
Mahim Alam Khan
Mahim Alam Khan 2017년 12월 27일
Ok.I got the problem but how will I stop the background getting updated. Here I am using GMM for background subtraction and is there any way I can stop the background getting updated everytime making stationary objects to become part of background.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2017년 12월 27일
You have to define how long a stationery part of the image can be in there before it's considered permanent. After all, if it's there long enough, how are we to know it's not just part of the furniture?
  댓글 수: 4
Mahim Alam Khan
Mahim Alam Khan 2017년 12월 27일
Ok thanks. But is there any way to tweak up the mentioned code in the question via some few lines of code. Please help..!!
Image Analyst
Image Analyst 2017년 12월 27일
Try adjusting NumTrainingFrames. And you might have to generate a new foregroundDetector periodically at the longer elapsed time period that you want, like every 5 minutes or so.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Computer Vision Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by