フィルターのクリア

MATLAB Figure file trouble

2 ビュー (過去 30 日間)
Lloyd
Lloyd 2013 年 9 月 16 日
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

採用された回答

Kevin Claytor
Kevin Claytor 2013 年 9 月 16 日
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 件のコメント
Walter Roberson
Walter Roberson 2013 年 9 月 16 日
After you set() the hObject string property, add a call to
drawnow()
Lloyd
Lloyd 2013 年 9 月 16 日
i already figured the answer
tboxName = [baseName num2str(counter) '.jpg']; set(handles.name,'String',tboxName);
Thank you :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by