Effacer les filtres
Effacer les filtres

How to play video after background subtraction with deployable video player?

2 vues (au cours des 30 derniers jours)
Shiloh Pho
Shiloh Pho le 12 Jan 2015
Commenté : Dima Lisin le 23 Jan 2015
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?

Réponses (1)

Dima Lisin
Dima Lisin le 15 Jan 2015
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 commentaires
Shiloh Pho
Shiloh Pho le 23 Jan 2015
Hello, thank you for your help.. Can I ask again? Is there any command in matlab that can delay each frame?
Dima Lisin
Dima Lisin le 23 Jan 2015
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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by