- I have changed the button's TAG to "button_capture"
- 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).
MATLAB Figure file trouble
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Kevin Claytor
on 16 Sep 2013
Since I don't have your full code, I have made two assumptions:
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 Comments
Walter Roberson
on 16 Sep 2013
After you set() the hObject string property, add a call to
drawnow()
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!