how to develop a FIFO for realtime image acquisition
이전 댓글 표시
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)
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!