I need help using image acquisition to record serveral AVI in a loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have been working with MATLAB for a while now but i'm still new at this and have run into a problem that i need help on. recently I have been writing a code using image acquisition to record a behavior pattern of some paramecium while using a loop function function. The code works fine for the 1st AVI but when it loops back to record the 2nd AVI MATLAB would stop recording. The code I use is:
for i = 1:720
vid = videoinput('dcam', 1, 'Y8_1024x768');
vid.ROIPosition = [91 17 933 706];
src = getselectedsource(vid);
vid.FramesPerTrigger = 1;
vid.FramesPerTrigger = 3000;
src.FrameRate = '15';
vid.LoggingMode = 'disk';
Name = ['F:\51recordings_',int2str(i),'.avi'];
diskLogger = avifile(Name, 'Compression', 'None', 'Quality', 75, 'keyframepersec', 2.14, 'FPS', 15);
diskLogger = set(diskLogger, 'Colormap', gray(256));
vid.DiskLogger = diskLogger;
preview(vid);
start(vid);
pause(240);
stoppreview(vid);
diskLogger = close(vid.DiskLogger);
close all
clear
end
MATLAB would give me this error:
??? Error using ==> videoinput.videoinput at 388
dcam: Cannot determine device attributes when the device is in use.
Please close any running instances of this device.
Error event occurred at 11:13:44 for video input object: Y8_1024x768-dcam-1.
dcam: Error writing data to the DiskLogger file.
Failed to find the open file handle.
??? dcam: Error writing data to the DiskLogger file.
Failed to find the open file handle.
i think i need to close the preview window but i have tried close all and close all force but none of those have worked. I'm not sure what i should do any help would be appreciated.
Thank you,
Minh Tong
0 Kommentare
Antworten (1)
Ilango
am 17 Jan. 2012
Hey,
I think i found out what the problem was. The images that are being recorded in the first video stays in the object memory. I think it stops MATLAB from recording more. So after
diskLogger = close(vid.DiskLogger);
add these two lines:
delete(vid)
clear vid
Worked for me.
0 Kommentare
Siehe auch
Kategorien
Mehr zu DCAM Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!