Can vision.ForegroundDetector work on GUI
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, Can I use GUI to display foreground from vision.ForegroundDetector? By using the same method I can extract the foreground. But in the GUI I can't display the foreground. Please help, thanks
3 Commenti
Risposta accettata
Leona Chan
il 15 Ago 2017
6 Commenti
Jiro Doke
il 15 Ago 2017
"Same method" as in using foregroundDetector in a loop with video frames?
I can't say for certain, but you may need to take the vision.ForegroundDetector initialization outside of the "loop". If I remember correctly, the detector uses past frames to estimate the background. Currently, in your snippet of code, you are recreating the detector for each frame, thus clearing the past frames from its algorithm. Just using your code snippet, you may need to change to something like this.
function playCallback(hObject,~,videoSrc,hAxes)
foregroundDetector = vision.ForegroundDetector('NumGaussians', 4, ...
'NumTrainingFrames', 60);
while strcmp(hObject.String, 'Pause') && ~isDone(videoSrc)
[frame,result] = getAndProcessFrame(videoSrc,foregroundDetector);
showFrameOnAxis(hAxes.axis1, frame);
showFrameOnAxis(hAxes.axis2, result);
end
end
function [frame,foreground] = getAndProcessFrame(videoSrc,foregroundDetector)
frame = step(videoSrc);
foreground = step(foregroundDetector, frame);
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Computer Vision with Simulink in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!