필터 지우기
필터 지우기

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 CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by