How do I set the interval of my snapshot in GUI in real time?

1 view (last 30 days)
I am counting dots per snapshot, how do I set the interval of the camera on snapshot? as well as how do I set it when the GUI detect the dots that is the time he will do the snapshot? refer code below ty for your help
% --- Executes on button press in snap_shot.
function start_snap_Callback(hObject, eventdata, handles)
% hObject handle to snap_shot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.ss,'string','start');
set(handles.stop_snap,'enable','on');
while strcmp(get(handles.ss,'string'),'start') == 1
wa = getsnapshot(vid);
axes(handles.snap_shot);
imshow(wa);
verybest; % image processing takes
set(handles.pres,'String',Ndots);

Answers (2)

Image Analyst
Image Analyst on 3 Feb 2013
You can insert a pause(numberOfSeconds) in your while loop to have it wait whatever length of time you want. After some number of snaps, you'll probably want to do
set(handles.ss,'string', 'Stop');
to get your while loop to exit, otherwise you'll be in that loop forever. I'm also not sure how verybest() gets its data.
  1 Comment
Image Analyst
Image Analyst on 4 Feb 2013
Regarding your "Answer" you posted below (instead of a comment to my Answer like you should have)...
You're not assigning the Ndots string, so that line will fail. Plus you have no way to ever exit the loop like I mentioned above.

Sign in to comment.


michael Longard
michael Longard on 3 Feb 2013
that is my problem now I am bad doing loop =(
this is the code on "verybest" as a image processing
sigma = 5; % Gaussian smoothing, adapted to the size of the eggs
thres = 0.9; % binary threshold, adapted to the brightness of the eggs
G = rgb2gray(im2double(wa));
B = im2bw(imfilter(G, fspecial('gaussian', sigma*3, sigma), 'replicate'), thres);
Bl = bwlabel(B);
Neggs = max(Bl(:))
how do I put that while on snapshot sir? =(
  2 Comments
Image Analyst
Image Analyst on 3 Feb 2013
In your main program, call it like this:
Neggs = verybest(wa); % Do image processing on this snapshot.
michael Longard
michael Longard on 4 Feb 2013
% --- Executes on button press in snap_shot.
function start_snap_Callback(hObject, eventdata, handles)
% hObject handle to snap_shot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.ss,'string','start');
set(handles.stop_snap,'enable','on');
while strcmp(get(handles.ss,'string'),'start') == 1
wa = getsnapshot(vid);
axes(handles.snap_shot);
imshow(wa);
Neggs = verybest(wa); % if true code
end
set(handles.pres,'String',Ndots);
is that correct sir? but I want snapshot is already set?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!