i have a capturing GUI, how do I save each image i capture in camera?
1 view (last 30 days)
Show older comments
this is the function button of capsave which get a snapshot of the camera then save the image.. how do i save the image every time I captured?
function capsave_Callback(hObject, eventdata, handles)
% hObject handle to capsave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.ss,'string','start');
load('pass_val_cam.mat', 'vid');
wa = getsnapshot(vid);
axes(handles.snap_shot);
imshow(wa);
newName = sprintf('.jpg');
imwrite(wa,['FINALS\' newName,]);
%disp(image_val);
% pause(ntrvl);
clc;
a
0 Comments
Accepted Answer
Chandra Kurniawan
on 17 Jan 2012
Hi, John
Can you find opening fcn in your code?
Something like
function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)
In the openingfcn you should write
handles.output = hObject;
handles.index = 0;
guidata(hObject, handles);
And in your capsave_Callback you should write
function capsave_Callback(hObject, eventdata, handles)
handles.output = hObject;
handles.index = handles.index + 1;
set(handles.ss,'string','start');
load('pass_val_cam.mat', 'vid');
wa = getsnapshot(vid);
axes(handles.snap_shot);
imshow(wa);
newName = strcat('picture',num2str(handles.index),'.jpg');
imwrite(wa,['FINALS\' newName,]);
guidata(hObject, handles);
0 Comments
More Answers (3)
john john
on 17 Jan 2012
5 Comments
Walter Roberson
on 17 Jan 2012
The
persistent imgnum
defines imgnum.
There is a small bug in what I wrote, though: after the "persistent" command, add
if isempty(imgnum); imgnum = 0; end
(This is not a fix to imgnum not being defined; that is the job of the "persistent" that needs to be in your callback.)
john john
on 18 Jan 2012
2 Comments
Chandra Kurniawan
on 18 Jan 2012
before line
imwrite(wa,['FINALS\' newName,]);
just write :
wa = imresize(wa,scale);
'scale' is scalar.
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!