ABSENSI MATLAB AUTO CAPTURE
% --- Executes on button press in btnZOOM.
function btnZOOM_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I = get(proyek.axes1,'Userdata');
%J = imresize(I, 2, 'nearest');
J = imresize(I, [512 NaN]);
set(proyek.proyekPD2,'CurrentAxes',proyek.axes2);
imshow(J);
figure, imshow(I), figure, imshow(J)
% --- Executes on button press in btnCrop.
function btnCrop_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I = get(proyek.axes1,'Userdata');
set(proyek.proyekPD2,'CurrentAxes',proyek.axes2);
imshow(I);
im=I;
f = imfreehand();
mask = f.createMask();
mask = repmat(mask,[1 1 3]);
im(~mask) = 0;
set(imshow(im));
set(proyek.axes2,'Userdata',im);
[ps]=['Crop gambar selesai'];
h = msgbox(ps, 'CROP','Help');% ICON:Warn Help Error
% --- Executes on button press in btnBrowse.
function btnBrowse_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
[proyek.namafile,proyek.direktori]=uigetfile({'*.bmp;*.jpg','file citra(*.bmp,*.jpg)';'*.bmp','file bitmap(*.bmp)';'*.jpg','file jpg(*.jpg)';'*.*','semua file(*.*)'},'buka file citra host/asli');
I=imread(fullfile(proyek.direktori,proyek.namafile));
if ~isequal(proyek.namafile, 0)
set(proyek.proyekPD2,'CurrentAxes',proyek.axes1);
set(imshow(I));
set(proyek.axes1,'Userdata',I);
[ps]=['Load gambar ' proyek.namafile ' berhasil'];
h = msgbox(ps, 'Load','Help');% ICON:Warn Help Error
else
return;
end
% --- Executes on button press in btnClearBG.
function btnClearBG_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I = get(proyek.axes1,'Userdata');
%%%%%%%hilangkan bground
H = fspecial('gaussian'); % Create the filter kernel.
I = imfilter(I,H); % Blur the image.
Mask = im2bw(I, 0.9); % Now we are generating the binary mask.
I([Mask, Mask, Mask]) = 0; % Now we have the image.
%%%%%%%%%%%%%%%%%%%%%%%%%
set(proyek.proyekPD2,'CurrentAxes',proyek.axes1);
imshow(I);
set(proyek.axes1,'Userdata',I);
msgbox('u CROP : Silakan drag di area yang diinginkan..','OK','Crop',I,[]);
% --- Executes on button press in btnCROPRect.
function btnCROPRect_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I = get(proyek.axes1,'Userdata');
set(proyek.proyekPD2,'CurrentAxes',proyek.axes2);
imshow(I);
[im,rect] = imcrop(I);
set(imshow(im));
set(proyek.axes2,'Userdata',im);
[ps]=['Crop gambar By Rectangle selesai'];
h = msgbox(ps, 'CROP RECT','Help');% ICON:Warn Help Error
% --- Executes on button press in myBtnReset.
function myBtnReset_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
mau=questdlg(['Reset ' get(proyek.proyekPD2,'Name')''],['Anda ingin Reset Aplikasi ini?'],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
else
arrayfun(@cla,findall(0,'type','axes'))
hm = msgbox('Reset','Reset Sukses','help');
end
% --- Executes on button press in btnCamera.
function btnCamera_Callback(hObject, eventdata, handles)
% InstalledAdaptors: {'coreco' 'winvideo'}
% MATLABVersion: '7.10 (R2010a)'
% ToolboxName: 'Image Acquisition Toolbox'
% ToolboxVersion: '3.5 (R2010a)'
%obj = videoinput('matrox', 1);
proyek=guidata(gcbo);
%vid = videoinput('winvideo',2, 'YUY2_176x144');
vid=videoinput('winvideo', 1);
vid.FramesPerTrigger = 1;
vid.ReturnedColorspace = 'rgb';
triggerconfig(vid, 'manual');
vidRes = get(vid, 'VideoResolution');
imWidth = vidRes(1);
imHeight = vidRes(2);
nBands = get(vid, 'NumberOfBands');
hImage = image(zeros(imHeight, imWidth, nBands), 'parent', proyek.axes1);
preview(vid, hImage);
set(proyek.axes1,'Userdata',vid);
start(vid);
pause(1);
trigger(vid);
stoppreview(vid);
I = getdata(vid);
FDetect = vision.CascadeObjectDetector;
BB = step(FDetect,I);
imshow(I);
hold on
for i = 1:size(BB,1)
BB(i,:)
rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
% 107 77 130 130
I = imcrop(I,BB);
I=imresize(I,[256 256]);
set(handles.proyekPD2,'CurrentAxes',handles.axes1);
hold off;
imshow(I);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%OK
TrainDatabasePath = 'TrainDatabase\';%uigetdir(strcat(matlabroot,'\work'), 'Select training database path' )
TestDatabasePath ='TestDatabase\';% uigetdir(strcat(matlabroot,'\work'), 'Select test database path')
% prompt = {'Enter test image name (a number between 1 to 10):'};
% dlg_title = 'Input of FLD-Based Face Recognition System';
% num_lines= 1;
% def = {'1'};
%
% TestImage = inputdlg(prompt,dlg_title,num_lines,def);
% TestImage = strcat(TestDatabasePath,'\',char(TestImage),'.jpg');
TestImage=I;
im = I;%imread(TestImage);
%200x180x3 108000 uint8
%53 90 131 131
%I 132x132x3 52272 uint8
T = CreateDatabase(TrainDatabasePath);
[m V_PCA V_Fisher ProjectedImages_Fisher] = FisherfaceCore(T);
OutputName = Recognition(TestImage, m, V_PCA, V_Fisher, ProjectedImages_Fisher);
SelectedImage = strcat(TrainDatabasePath,'\',OutputName);
SelectedImage = imread(SelectedImage);
imshow(SelectedImage)
str = strcat('Matched image is : ',OutputName);
set(handles.edNis,'String',OutputName);
disp(str)
% --- Executes on button press in btnCapture.
function btnCapture_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
vid= get(proyek.axes1,'Userdata');
disp('============');
whos vid
start(vid);
pause(3);
trigger(vid);
stoppreview(vid);
I = getdata(vid);
imwrite(I, 'captured.png');
warndlg('Capture berhasil....!');
set(imshow(I));
set(proyek.axes1,'Userdata',I);
% --- Executes on button press in btnSave.
function btnSave_Callback(hObject, eventdata, handles)
% proyek=guidata(gcbo);
% counter = 1;
% img= get(proyek.axes1,'Userdata');
% baseDir = '';%'C:\Users\Sony Vaio\Documents\Task\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);
[handles.namafile,handles.direktori]=uiputfile({'*.bmp;*.jpg','file citra(*.bmp,*.jpg)';'*.bmp','file bitmap(*.bmp)';'*.jpg','file jpg(*.jpg)';'*.*','semua file(*.*)'},'simpan file citra');
al=fullfile(handles.direktori,handles.namafile)
I=get(handles.axes1,'Userdata');
gbr=imresize(I,[256 256]);
imwrite(gbr,al);
msgbox(['The new image @ ' handles.direktori '\' handles.namafile ' has Succesfully to Save']);
% --- Executes on button press in btnClose.
function btnClose_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
mau=questdlg(['Keluar ' get(proyek.aplikasi,'Name')''],['Anda ingin Keluar dari Aplikasi ini?'],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
end
delete(proyek.aplikasi);
% --- Executes on button press in BTNaUTO.
function BTNaUTO_Callback(hObject, eventdata, handles)
FDetect = vision.CascadeObjectDetector;
I = get(handles.axes1,'Userdata');
BB = step(FDetect,I);
imshow(I);
hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
hold off;
function btnLoad_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
[handles.namafile,handles.direktori]=uigetfile({'*.bmp;*.jpg','file citra(*.bmp,*.jpg)';'*.bmp','file bitmap(*.bmp)';'*.jpg','file jpg(*.jpg)';'*.*','semua file(*.*)'},'buka file citra host/asli');
I=imread(fullfile(handles.direktori,handles.namafile));
FDetect = vision.CascadeObjectDetector;
BB = step(FDetect,I);
imshow(I);
hold on
for i = 1:size(BB,1)
BB(i,:)
rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
% 107 77 130 130
I = imcrop(I,BB);
set(handles.proyekPD2,'CurrentAxes',handles.axes1);
hold off;
imshow(I);
set(handles.axes1,'Userdata',I);
uhh pusing.....lbh mendalam lg......lp2maray.com ya u pembahasannya