MATLAB图文件故障

时间:2013-09-16 18:27:01

标签: matlab image-processing matlab-figure figure

捕获按钮可捕获图像并将其保存在单个文件夹中。每当我按下捕获按钮时,它将继续捕获并保存图像。我想要做的是每当我按捕获按钮时,它会自动更新 image1.jpg文本框

  

说清楚:

     每次点击捕获按钮编辑文本框都会更新它   name to image1.jpg,1再次点击Capture,Textbox更新到   image2.jpg等....请帮帮我:(

enter image description here

“捕获”按钮的代码为

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

“文本框”中显示的“流程按钮”代码

 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 个答案:

答案 0 :(得分:1)

我不确定您是否发布了捕获按钮的推送回调的完整代码,但我没有看到您在任何地方设置编辑框的String属性。

set(hEditBox,'String',newName);

如果您要在handles中设置字段,请不要忘记guidata(hObject,handles)