alternative to using preview with logging to memory to avoid dropped frames

1 view (last 30 days)
I would like to capture a gigE camera data stream that is 14 bit and save it to a hardrive. my current method drops a frame every now and then, like 1 per second or so. I have found that preview with logging=disk works great but saves AVIs that are 8 bit. I would really like preview to show the image with agc ( so i can see what is happening) and save it as 14 bit without the agc applied ( so it can be post processed later). I am close to having this work by saving a stacked tiff, but still suffer from a dropped frame every now and then. The loop below is the fastest I think I can go, but I am blind because there is no display and there is still a dropped frame every now and then. Here i am writing a stacked tiff, maybe some other format would be faster? image sizes can be 640x480 to hd format
while ishandle(hh)
img = getsnapshot(vid);
imwrite(img,fullname,'WriteMode','append','Compression','none');
end

Answers (1)

Bego
Bego on 16 Sep 2016
Hi Gerard!
I'm working on something similar. Yesteday I precisely asked a question in Maltab Answers about this situation. Although I haven't been given a working solution I think I'm close to it.
Have you seen the example ' myCameraGUI.m ' provided by the MathWorks Support Team? Well if you give it a look, you could re-use the strategy of having a GUI with an axes component, in which you constantly view the camera's acquisition.
On the other hand, have you tried using function peekdata() to save individual frames as they are acquired?
handles.video.FramesAcquiredFcnCount = 1;
handles.video.FramesPerTrigger = fps;
%Once all desired frames are acquired, video input will stop
handles.video.TriggerRepeat = numberofFramesToAquire;
....%Additional video input configuration
start(handles.video);
sample_frame = peekdata(obj,1);
imwrite(sampleframe,saveRoute);
drawnow;
This way by using peekdata(), information will still be on the buffer and at the very end of the acquisition you can write it all down using:
videodata = getdata(handles.video)
save(filename,'videodata');
Hope this helps.

Products

Community Treasure Hunt

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

Start Hunting!