summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2012-09-18 09:20:37 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2012-09-18 09:20:37 -0400
commit5443013a9d026c3d5c833c211b971023404b6a87 (patch)
treea3be17a78234488f0d1f376354723950d3fc4917
parenta1b55f03e2fe40d4e14278745eae473b73fe81fe (diff)
downloadbeam_profiler-5443013a9d026c3d5c833c211b971023404b6a87.tar.gz
beam_profiler-5443013a9d026c3d5c833c211b971023404b6a87.zip
simplified logic for continuous and single run
For whatever reason pushing stop does not do a thing
-rw-r--r--gui_win.m44
1 files changed, 13 insertions, 31 deletions
diff --git a/gui_win.m b/gui_win.m
index e272f55..065ba7f 100644
--- a/gui_win.m
+++ b/gui_win.m
@@ -63,12 +63,12 @@ handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
+
% Set color of the strart button to green
set(handles.button2start,'BackgroundColor','Green');
% Declare global variables
global background_m;
-global image_name;
global isworking;
global image_display;
global image_original;
@@ -82,7 +82,6 @@ image_display = 0;
image_original = 0;
image_cleaned = 0;
image_fitted = 0;
-image_name = 'test.png';
image_cross = 0;
isworking = 0;
@@ -109,17 +108,6 @@ varargout{1} = handles.output;
-% This funcion just calls the external program which takes an image from camera
-% We call it with parameters read from the GUI fields
-function grabimage(handles)
-global image_name;
-global image_display;
-global image_original;
-run_string = horzcat('grabNimages_1394cam.exe -s ',num2str(get(handles.readshutterspeed,'String')),' -n ',num2str(get(handles.readnumber,'String')));
-[status,result] = system(run_string);
-img=imread(image_name);
-image_display=double(img);
-image_original=image_display;
@@ -149,6 +137,15 @@ drawnow;
+function grab_image_and_update_display(handles)
+global image_display;
+global image_original;
+shutter_time = num2str(get(handles.readshutterspeed,'String'));
+Naverages = get(handles.readnumber,'String');
+image_original = grabimage(shutter_time, Naverages);
+image_display = image_original;
+display_stuff(handles);
+
% This function is executed when START button is pressed.
@@ -176,29 +173,15 @@ set(handles.button2start,'BackgroundColor','Red');
set(handles.button2start,'String','STOP');
drawnow; % needed to draw this before doing fit
-
-
-
-
% This is for the single run
if get(handles.button2singlerun,'Value')
-
- % Grab an image from camera
- grabimage(handles);
- display_stuff(handles);
-
+ grab_image_and_update_display(handles);
end;
-
-
-
-
-% This executes when we do the continious run
-% Same as the single fit exept that we have a while cycle
+% This executes when we do the continuous run
if get(handles.button2comtinuousrun,'Value')
while get(handles.button2start,'Value') > 0
- grabimage(handles);
- display_stuff(handles);
+ grab_image_and_update_display(handles);
end;
end;
@@ -491,7 +474,6 @@ function button2save_Callback(hObject, eventdata, handles)
% hObject handle to button2save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
-global image_name;
global image_display;
%fname_to_save = horzcat(pwd,filesep,'saved_images',filesep,datestr(now, 'yyyy_mm_dd_HHMMSS'),'.png');
fname_to_save = horzcat('Z:\beam_profiler images',filesep,datestr(now, 'yyyy_mm_dd_HHMMSS'),'.png');