-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_detect_eyeleft.asv
88 lines (83 loc) · 2.56 KB
/
main_detect_eyeleft.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
%% Chuong trinh chay va hien thi cac ket qua cho ve hai mat
% Xac dinh cac goc cac khoang cach cho dau vao cua mang noron.
% By : Nguyen Van Linh
% SipLab_k52, Dien tu vien thong, Dai hoc Bach Khoa Ha Noi.
clc
clear all
ketqua = 'ketqua1\';
%% Thiet lap cac tham so cho dong video dau vao.
vid = videoinput('winvideo',1,'YUY2_640x480');
set(vid,'Returnedcolorspace','rgb');
set(vid,'FramesPerTrigger',1);
set(vid,'TriggerRepeat',Inf);
triggerconfig(vid,'manual');
vid.FrameGrabInterval = 0.5;
%preview(vid);
%% Thu nhan anh va bat dau xu ly.
%num_frames = input('\n Dai ca vui long nhap so luong farme :');
pause(2);
%start(vid);
%try
%while(vid.FramesAcquired<=num_frames)
heso = [];
try
%trigger(vid);
%Image = getdata(vid,1);
Image = getsnapshot(vid);
Ima = imresize(Image,0.25);
% Tim da vung da nguoi va trung tam cua vung da do
[face,Center,Yaveg] = tim_vungda(Image);
% Cat da vung co chua con mat.
figure, imshow(face)
[anhtrai,C] = cut_eyeleftregion(Image,face,Center);
% Resize anh lon de thuc hien template matching cho thoi gian tinh toan
% nhanh
figure, imshow(anhtrai)
resize_anhtrai = imresize(anhtrai,0.25);
[xtrai,ytrai] = tim_mattrai(resize_anhtrai);
xtrai = 4*xtrai+C(1);
ytrai = 4*ytrai+C(2);
try
[boxmattrai,xtranform,ytranform] = catanh(Image,xtrai,ytrai,18,15,40,40);
catch Me
stop(vid);
error('Loi cho nay');
vid.FramesAcquired = vid.FramesAcquired-1;
continue;
end
%[eL_cL,eL_cR,C1,C2,C3,o_eye_left] = eyeleft_corner(boxmattrai);
catch Me
vid.FramesAcquired = vid.FramesAcquired-1;
continue;
end
%% Gio quan tam den mat ben phai
% Khi da biet mat ben trai, ta dua vao do de trich ra vung mat ben phai
%[anhphai,lech] = cut_eyerightregion(Image,xtrai,Center);
%subplot(2,1,1),imshow(anhphai)
%hold on
%plot(C2+ytranform,C1+xtranform,'*r')
%hold off
%subplot(2,1,2)
%imshow(o_eye_left)
%hold on
%plot(eL_cL(2),eL_cL(1),'*b')
%plot(eL_cR(2),eL_cR(1),'*b')
%plot(C2,C1,'*r')
%plot(C2+C3,C1,'*b')
%plot(C2-C3,C1,'*b')
%plot(C2,C1+C3,'*b')
%plot(C2,C1-C3,'*b')
%plot([eL_cL(2) C2],[eL_cL(1) C1],'-','Color','green')
%plot([eL_cR(2) C2],[eL_cR(1) C1],'-','Color','green')
%hold off
%subplot(2,2,3),imshow(anhtrai)
figure,imshow(anhtrai)
figure, imshow(boxmattrai)
vid.FramesAcquired
%end
%catch Me
stop(vid);
%end
stop(vid);
delete(vid);
clear vid;