How to play video after background subtraction with deployable video player?
조회 수: 2 (최근 30일)
이전 댓글 표시
This is my first time using MATLAB, I'm still adapting myself with the language.. What I want to ask is, if I just used this code from help document for gaussian mixture model background substraction:
videoSource = vision.VideoFileReader('3.avi','ImageColorSpace','Intensity','VideoOutputDataType','uint8');
detector = vision.ForegroundDetector(...
'NumTrainingFrames', 5, ... % 5 because of short video
'InitialVariance', 30*30); % initial standard deviation of 30
blob = vision.BlobAnalysis(...
'CentroidOutputPort', false, 'AreaOutputPort', false, ...
'BoundingBoxOutputPort', true, ...
'MinimumBlobAreaSource', 'Property', 'MinimumBlobArea', 250);
shapeInserter = vision.ShapeInserter('BorderColor','White');
videoPlayer = vision.VideoPlayer();
while ~isDone(videoSource)
frame = step(videoSource);
fgMask = step(detector, frame);
bbox = step(blob, fgMask);
out = step(shapeInserter, frame, bbox); % draw bounding boxes around cars
step(videoPlayer, out); % view results in the video player
end
release(videoPlayer);
release(videoSource);
the video playing so fast.. And I found if I play video only without background substraction with deployable video player, it's play like in windows movie player.. My question is how I can play with deployable video player after using gaussian mixture model background substraction?
댓글 수: 0
답변 (1개)
Dima Lisin
2015년 1월 15일
Hi Shiloh,
the line
step(videoPlayer, out); % view results in the video player
tells the vision.VideoPlayer object to display image out, which is the original video frame with the bounding boxes. If you want to show the result of the background subtraction, you should replace out with fgMask.
If you wish to use vision.DeployableVideoPlayer, then you should simply replace
videoPlayer = vision.VideoPlayer();
with
videoPlayer = vision.DeployableVideoPlayer();
You can also play the video and the foreground mask side by side using two video players. See the Motion-Based Multiple Object Tracking example.
댓글 수: 2
Dima Lisin
2015년 1월 23일
Hi Shiloh,
I am not quite sure what you mean by "delay"... Is your video playing too fast? You can use the pause function to cause matlab to wait for some amount of time.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!