1
votes

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 :(

enter image description here

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);
1
Have you tried setting the text box's String property? set(hTextBox,'String',newName); - chappjc
@chappjc sorry forgot to say that the textbox just serves as the display of the Process pushbutton. The textbox has no property. - lloydknight
To put the file name in the Edit Textbox, you still need to use the String property. Is the problem how to get the file name stripped away from the full file path? For that, use fileparts. - chappjc
the image1.jpg is just a String name. I still have to change image1.jpg to image2.jpg manually. the textbox has no property. The Process button just gets what was in the textbox - lloydknight
The process button gets what was in the text box via the String property. Try doing set(handles.name,'String','imageX.jpg') in the capture button code, as in my answer below. - chappjc

1 Answers

1
votes

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).