MATLAB Figure file trouble

1 vue (au cours des 30 derniers jours)
Lloyd
Lloyd le 16 Sep 2013
The Capture button does capture images and saves it on a single folder. Whenever I'll push the Capture button It'll just keeps on capturing and saving images. What I want to do is whenever I will push Capture button, it will automatically update the image1.jpg textbox.
To make things clear:
Every hit to Capture button, the Edit textbox updates it's name to image1.jpg, 1 hit again to Capture, Textbox updates to image2.jpg etc.... please help me :(
The Capture button's code is
vid = videoinput('winvideo', 1);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
imshow(img);
%this is where the image will be saved
counter = 1;
baseDir = 'C:\Users\Sony Vaio\Documents\Task\Appendix\images\';
baseName = 'image';
newName = [baseDir baseName num2str(counter) '.jpg'];
while exist(newName,'file')
counter = counter + 1;
newName = [baseDir baseName num2str(counter) '.jpg'];
end
imwrite(img, newName);
The Textbox's code is
function name_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Réponse acceptée

Kevin Claytor
Kevin Claytor le 16 Sep 2013
Since I don't have your full code, I have made two assumptions:
  1. I have changed the button's TAG to "button_capture"
  2. Make sure your capture button code returns newName (if it is a separate function, if you do that in the callback, then don't worry).
Now find the callback when the button is pressed.
This will then be something like:
function button_capture_Callback(hObject, eventdata, handles)
% Run the capture button code
[newName] = capture_button_code(varargin);
% hObject is the calling object, ie; our button, we now update it's string
set(hObject,'String',newName)
  2 commentaires
Walter Roberson
Walter Roberson le 16 Sep 2013
After you set() the hObject string property, add a call to
drawnow()
Lloyd
Lloyd le 16 Sep 2013
i already figured the answer
tboxName = [baseName num2str(counter) '.jpg']; set(handles.name,'String',tboxName);
Thank you :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by