Reputation: 57
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', 2);
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 Process Pushbutton's code that appears in Textbox
name=get(handles.name,'String');
A=imread(strcat('images/',name));
org=A;
axes(handles.axes1);
[h,w,f]=size(A);
%original image is shown
imshow(A);
Upvotes: 1
Views: 258
Reputation: 30579
I'm not sure you posted the whole code for your capture button's push callback, but I don't see you setting your edit box's String
property anywhere.
set(hEditBox,'String',newName);
If you are setting fields in handles
, don't forget to guidata(hObject,handles)
.
Upvotes: 1