How can you stop live video from playing in the GUI?
Ältere Kommentare anzeigen
Hi, I have code that displays video footage from a camera in a GUI. I am unable to stop this video once it starts, the code that I copied to get the image to display tells the user to close the image simply by clicking on the "x" button on the top right corner. The problem with this, is that the "x" box is not visible once the image runs inside my GUI.
Most attempts either are ignored or cause matlab to freeze/hang. I believe a loop is running when I try to close the video and it simply ignores the close request.
disp('iCam Live Mode Preview')
PrepareAcquisition()
% init system
disp('Initialising Camera');
ret=AndorInitialize('');
CheckError(ret);
disp('Configuring Acquisition');
[ret]=CoolerON(); % Turn on temperature cooler
CheckWarning(ret);
[ret]=SetAcquisitionMode(5); % Set acquisition mode; 5 for RTA
CheckWarning(ret);
[ret]=SetExposureTime(0.02); % Set exposure time in second
CheckWarning(ret);
[ret]=SetReadMode(4); % Set read mode; 4 for Image
CheckWarning(ret);
[ret]=SetTriggerMode(10); % Set Software trigger mode
useSoftwareTrigger = true;
if ret == atmcd.DRV_INVALID_TRIGGER_MODE
disp('Software trigger not available, using Internal trigger instead')
SetTriggerMode(0); % Set internal trigger mode
useSoftwareTrigger = false;
end
CheckWarning(ret);
[ret]=SetShutter(1, 1, 0, 0); % Open Shutter
CheckWarning(ret);
[ret,XPixels, YPixels]=GetDetector; % Get the CCD size
CheckWarning(ret);
[ret]=SetImage(1, 1, 1, XPixels, 1, YPixels); % Set the image size
CheckWarning(ret);
disp('Starting Acquisition');
[ret] = StartAcquisition();
CheckWarning(ret);
I = zeros(YPixels,XPixels);
h = imagesc(I);
colormap(gray);
warndlg('To Abort the acquisition close the image display.','Starting Acquisition');
while(get(0,'CurrentFigure'))
if useSoftwareTrigger == true
[ret] = SendSoftwareTrigger();
CheckWarning(ret);
[ret] = WaitForAcquisition();
CheckWarning(ret);
end
[ret, imageData] = GetMostRecentImage(XPixels * YPixels);
CheckWarning(ret);
if ret == atmcd.DRV_SUCCESS
%display the acquired image
I=flipdim(transpose(reshape(imageData, XPixels, YPixels)),1);
set(h,'CData',I);
drawnow;
end
end
disp('Acquisition Complete! Cleaning Up and Shutting Down');
[ret]=AbortAcquisition;
CheckWarning(ret);
[ret]=SetShutter(1, 2, 1, 1);
CheckWarning(ret);
[ret]=AndorShutDown;
CheckWarning(ret);
I tried to use the last 6 or 7 lines of this code as a separate "stop" button but this occurs once pressed, most of the time I cant even open the main matlab window to see due to it hanging...

Can someone explain how I can close or stop this video without matlab crashing?
Thanks Johnny
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Image Preview and Device Configuration finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!