how to develop a FIFO for realtime image acquisition

2 visualizaciones (últimos 30 días)
AngryMob
AngryMob el 29 de Mayo de 2018
Respondida: AngryMob el 1 de Jun. de 2018
I want to create a FIFO for real time face tracking with my webcam. To prevent a memory overflow i want to create something like a FIFO. I thought grabbing the images with „peekdata“ and releasing them with „fluemshdata“ would do the job. However cheking the memory shows that the memory used by matlab is still increasing. So what ist he best way to do that? Thank you very much.
My code so far:
%%real time video
% be shure you installed the
% "Image Acquisition Toolbox Support Package for OS Generic Video Interface" - Add on
%%Initialise Video
% list of all installed adaptors
imaqhwinfo
% my fist webcam:
info = imaqhwinfo('winvideo',2);
try
% Create a Video Input Object
vid = videoinput('winvideo',2,info.DefaultFormat);
catch
stop(vid);
clear vid;
vid = videoinput('winvideo',2,info.DefaultFormat);
end
% continuous image acquisition:
vid.TriggerRepeat = Inf;
vid.FrameGrabInterval = 1;
vid.FramesPerTrigger=1;
%videoPlayer = vision.VideoPlayer;
%videoPlayer.Position=vid.ROIPosition+50;
start(vid);
% Track the face over successive video frames until the video is finished.
while 1
% Extract the next video frame
frame=peekdata(vid,1);
%frame=getsnapshot(vid);
% to prevent memoryissues - remove the oldest trigger data -
% we have now something like a FIFO (ring bufffer). We keep the newest
% 100 Frames
flushdata(vid,'trigger');
memo=memory
end
%%clear up
flushdata(vid);
stop(vid);
delete(vid);
imaqreset; % Disconnect and delete all image acquisition objects
close(gcf)

Respuestas (1)

AngryMob
AngryMob el 1 de Jun. de 2018
I found a sollution. Like always i did not understand how the videoinput object really works. Instead of one flushdata i repeat the flushing till only 100 frames are stored in the buffer... so keeping the memory constant...
while vid.FramesAvailable>100
flushdata(vid,'trigger');
end
I still think there must be a more elegant sollution ....

Community Treasure Hunt

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

Start Hunting!

Translated by