ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ BÀN TAY (có code và sơ đồ mạch)

52 893 5
ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ BÀN TAY (có code và sơ đồ mạch)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ĐỒ ÁN TỐT NGHIỆP ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ BÀN TAY MỤC LỤC DANH MỤC CÁC HÌNH VẼ VII DANH MỤC CÁC BẢNG BIỂU VIII DANH MỤC CÁC TỪ VIẾT TẮT IX CHƯƠNG TỔNG QUAN VỀ ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ TAY 1.1 GIỚI THIỆU ĐỀ TÀI 1.1.1 Mục đích nghiên cứu .1 1.1.2 Phương pháp nghiên cứu 1.2 ĐỊNH NGHĨA VỀ PHƯƠNG PHÁP NHẬN DIỆN CỬ CHỈ BÀN TAY CHƯƠNG CÁC KHÁI NIỆM CƠ BẢN VỀ ẢNH .3 2.1 ẢNH SỐ VÀ ĐIỂM ẢNH (PIXEL) 2.2 MỨC XÁM CỦA ẢNH 2.3 CÁC LOẠI ẢNH 2.3.1 Ảnh nhị phân 2.3.2 Ảnh xám 2.3.3 Ảnh màu RGB CHƯƠNG PHƯƠNG PHÁP PHÂN TÍCH THÀNH PHẦN CHÍNH PCA 3.1 TÌM HIỂU VỀ PCA 3.2 THUẬT TOÁN PCA TRONG NHẬN DIỆN CỬ CHỈ BÀN TAY 3.2.1 Nhận ảnh bàn tay từ sở liệu – tập ảnh huấn luyện 3.2.2 Tính giá trị vector trung bình 3.2.3 Trừ giá trị trung bình 3.2.4 Tính ma trận hiệp biến 3.2.5 Tính trị riêng vector đặc trưng ma trận hiệp biến 3.2.6 Lựa chọn thành phần xây dựng vector đặc trưng 3.2.7 Tính giá trị £j CHƯƠNG THIẾT KẾ HỆ THỐNG 10 4.1 SƠ ĐỒ KHỐI HỆ THỐNG 10 4.2 KHỐI NHẬN DIỆN CỬ CHỈ BÀN TAY 11 4.2.1 Xây dựng liệu huấn luyện 11 4.2.2 Thu nhận tín hiệu, tiền xử lý 11 4.2.3 Trích chọn đặc trưng .12 4.2.4 Giai đoạn nhận dạng cử phân loại cử 12 4.3 KHỐI ĐIỀU KHIỂN THIẾT BỊ 13 CHƯƠNG CHƯƠNG TRÌNH NHẬN DIỆN CỬ CHỈ BÀN TAY 14 5.1 YÊU CẦU 14 5.2 PHÂN TÍCH CHƯƠNG TRÌNH 14 5.2.1 Xây dựng sở liệu 14 5.2.2 Nhận diện cử bàn tay .16 5.3 THIẾT KẾ CHƯƠNG TRÌNH 17 5.3.1 Giao diện chương trình 17 5.3.2 Hoạt động chương trình 18 5.4 KẾT QUẢ VÀ ĐÁNH GIÁ 20 CHƯƠNG MƠ HÌNH ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ BÀN TAY .21 6.1 KHỐI RELAY 21 6.1.1 Thông số kỹ thuật relay easy 21 6.1.2 Sơ đồ thiết kế relay easy 22 6.2 KHỐI XỬ LÝ CHÍNH 23 6.2.1 Arduino UNO R3 23 6.2.2 Sơ đồ nguyên lý mạch điều khiển thiết bị 24 6.3 MƠ HÌNH HỒN THIỆN 24 CHƯƠNG KẾT LUẬN VÀ HƯỚNG PHÁT TRIỂN ĐỀ TÀI .26 7.1 KẾT LUẬN 26 7.2 HƯỚNG PHÁT TRIỂN 26 TÀI LIỆU THAM KHẢO 28 PHỤ LỤC 29 DANH MỤC CÁC HÌNH VẼ HÌNH 2-1: ẢNH NHỊ PHÂN [5] HÌNH 2-2: ẢNH XÁM [5] HÌNH 2-3: ẢNH MÀU RGB [5] HÌNH 3-1: CÁC PHÉP CHIẾU TRÊN TRỤC TỌA ĐỘ KHÁC NHAU CHO CÁCH NHÌN KHÁC NHAU VỀ CÙNG MỘT DỮ LIỆU [5] HÌNH 3-2: TÌM TRỤC TỌA ĐỘ MỚI SAO CHO DỮ LIỆU CĨ ĐỘ BIẾN THIÊN CAO NHẤT [5] HÌNH 3-3: CÁC ẢNH HUẤN LUYỆN CĨ CÙNG KÍCH THƯỚC HÌNH 4-1: SƠ ĐỒ KHỐI HỆ THỐNG 10 HÌNH 4-2: SƠ ĐỒ KHỐI HỆ THỐNG NHẬN DIỆN CỬ CHỈ BÀN TAY .11 HÌNH 4-3: SƠ ĐỒ KHỐI HỆ THỐNG ĐIỀU KHIỂN THIẾT BỊ 13 HÌNH 5-1: MỘT PHẦN CỦA TẬP ẢNH LUYỆN .14 HÌNH 5-2: LƯU ĐỒ THUẬT TỐN TRONG TẬP ẢNH LUYỆN 15 HÌNH 5-3: LƯU ĐỒ THUẬT TOÁN NHẬN DIỆN CỬ CHỈ BÀN TAY 16 HÌNH 5-4: GIAO DIỆN CHÍNH CHƯƠNG TRÌNH 18 HÌNH 5-5: GIAO DIỆN TẠO CƠ SỞ DỮ LIỆU 18 HÌNH 5-6: GIAO DIỆN CHỌN TẬP ẢNH HUẤN LUYỆN .19 HÌNH 5-7: GIAO DIỆN ĐƯA ẢNH VÀO NHẬN DẠNG 19 HÌNH 6-1: RELAY EASY [6] 21 HÌNH 6-2: SƠ ĐỒ THIẾT KẾ RELAY EASY 22 HÌNH 6-3: ARDUINO UNO R3 [7] 23 HÌNH 6-4: SƠ ĐỒ NGUYÊN LÝ MẠCH ĐIỀU KHIỂN THIẾT BỊ 24 HÌNH 6-5: MƠ HÌNH KHỐI ĐIỀU KHIỂN THIẾT BỊ .24 HÌNH 6-6: MƠ HÌNH ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ BÀN TAY 25 DANH MỤC CÁC BẢNG BIỂ BẢNG 5-1: BẢNG ĐÁNH GIÁ NHẬN DIỆN THEO TỪNG PHƯƠNG PHÁP .20 DANH MỤC CÁC TỪ VIẾT TẮT PCA Principal Component Analysis Trang 1/46 CHƯƠNG TỔNG QUAN VỀ ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ TAY 1.1 Giới thiệu đề tài Hiện ta có nhiều kỹ thuật hận diện như: nhận diện khuôn mặt , nhận dạng vân tay, … ứng dụng nhiều lĩnh vực Và đồ án tốt nghiệp này, em xin trình bày kỹ thuật nhận dạng khác nhận dạng cử bàn tay Cử bàn tay sử dụng hiệu để đưa lệnh điều khiển thiết bị, từ ta sử dụng chúng số lượng lớn ứng dụng 1.1.1 Mục đích nghiên cứu Tìm hiểu lý thuyết xử lí ảnh MATLAB Tìm hiểu phương pháp phân tích thành phần PCA ứng dụng vào đề tài Xây dựng ứng dụng có khả nhận dạng cử bàn tay dùng cho việc điều khiển thiết bị 1.1.2 Phương pháp nghiên cứu Tìm hiểu lý thuyết:  Các thuật toán nhận dạng cử bàn tay  Phương pháp PCA  Phương pháp lập trình MATLAB Tiến hành thực nghiệm:  Từ lý thuyết PCA, ứng dụng vào lập trình MATLAB tạo chương trình nhận diện cử bàn tay  Mô đánh giá kết thực nghiệm  Kết nối phần mềm với phần cứng điều khiển Điều khiển thiết bị dùng cử bàn tay Trang 2/46 1.2 Định nghĩa phương pháp nhận diện cử bàn tay Nhận diện cử bàn tay phương pháp dùng kỹ thuật máy tính để xác định cử bàn tay mà cụ thể đồ án đếm số ngón tay thể Từ dùng để phát triển ứng dụng điều khiển thiết bị Điều khiển thiết bị dùng cử bàn tay Trang 3/46 CHƯƠNG CÁC KHÁI NIỆM CƠ BẢN VỀ ẢNH 2.1 Ảnh số điểm ảnh (pixel) Ảnh số tập hợp hữu hạn điểm ảnh có mức xám phù hợp dùng để mô tả ảnh gần giống với ảnh thật Số điểm ảnh xác định độ phân giải ảnh Điểm ảnh (Pixel) phần tử ảnh số toạ độ (x, y) có độ xám màu định Kích thước với khoảng cách điểm ảnh chọn cho mắt người cảm nhận liên tục khơng gian mức xám (hoặc màu) ảnh số gần ảnh thật Và phần tử ma trận gọi phần tử ảnh 2.2 Mức xám ảnh Mức xám ảnh kết biến đổi tương ứng giá trị độ sáng điểm ảnh với giá trị ngun dương Thơng thường xác định [0, 255] tuỳ thuộc vào giá trị mà điểm ảnh biểu diễn Các thang giá trị mức xám thông thường là: 16, 32, 64, 128, 256 2.3 Các loại ảnh 2.3.1 Ảnh nhị phân Giá trị tất điểm ảnh nhận giá trị 0, điểm ảnh ảnh nhị phân biểu diễn bit Hình 2-1: Ảnh nhị phân [5] Điều khiển thiết bị dùng cử bàn tay Trang 4/46 2.3.2 Ảnh xám Giá trị điểm ảnh nằm khoảng [0 255], điểm ảnh ảnh xám biểu diễn byte bits Hình 2-2: Ảnh xám [5] 2.3.3 Ảnh màu RGB Ảnh màu gọi ảnh “Truecolor”, đựợc biểu diễn ma trận với chiều có kích thước (MxN)x3, MxN kích thước ảnh theo pixel Mỗi điểm ảnh có giá trị gồm có màu : màu đỏ (Red) + xanh lục (Green) + xanh dương (Blue) Hình 2-3: Ảnh màu RGB [5] Điều khiển thiết bị dùng cử bàn tay Trang 32/46 gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % - Executes just before hand_gesture is made visible function hand_gesture_OpeningFcn(hObject, eventdata, handles, varargin) global data if exist('data.mat','file') load data.mat end camera_ID=imaqhwinfo('winvideo','DeviceIDs'); set(handles.camera,'string',['Select Camera';camera_ID']); set(handles.init_button,'enable','off'); set(handles.preview_button,'enable','off'); global timer1 timer1=timer('TimerFcn',{@timer1_function,hObject,handles}, 'Period',0.5,'ExecutionMode','FixedRate'); % Choose default command line output for hand_gesture serialPorts = instrhwinfo('serial'); set(handles.com_port_list, 'String', [{'Select a port'} ; serialPorts.SerialPorts ]); handles.ser_com=''; handles.output = hObject; % Update handles structure guidata(hObject, handles); Điều khiển thiết bị dùng cử bàn tay Trang 33/46 % UIWAIT makes hand_gesture wait for user response (see UIRESUME) % uiwait(handles.figure1); % - Outputs from this function are returned to the command line function varargout = hand_gesture_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; % - Executes on button press in close function close_Callback(hObject, eventdata, handles) % hObject handle to close (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global vid; if ~isempty(handles.ser_com) if strcmp(get(handles.ser_com,'Status'),'open') fclose(handles.ser_com); end end if ~isempty(vid)&& strcmp('on',get(vid,'Running')) stop(vid); end global data save('data.mat','data'); close; % - Executes on selection change in camera function camera_Callback(hObject, eventdata, handles) global ID; ID=get(hObject,'Value'); if ID==1 errordlg('Vui Long Chon So!'); else Điều khiển thiết bị dùng cử bàn tay Trang 34/46 ID=ID-1; set(handles.init_button,'enable','on'); end % Hints: contents = cellstr(get(hObject,'String')) returns camera contents as cell array % contents{get(hObject,'Value')} returns selected item from camera % - Executes during object creation, after setting all properties function camera_CreateFcn(hObject, eventdata, handles) % hObject handle to camera (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % - Executes on button press in preview_button function preview_button_Callback(hObject, eventdata, handles) function init_button_Callback(hObject, eventdata, handles) global ID; global vid; global timer1 stop(timer1); if isempty(vid) vid=videoinput('winvideo',ID,'YUY2_640x480','returnedcolorspace','rgb'); vid.TriggerRepeat = Inf; triggerconfig(vid, 'manual'); set(vid,'Framespertrigger',1); Điều khiển thiết bị dùng cử bàn tay Trang 35/46 else stop(vid); delete(vid); vid=videoinput('winvideo',ID,'YUY2_640x480','returnedcolorspace','rgb'); vid.TriggerRepeat = Inf; triggerconfig(vid, 'manual'); set(vid,'Framespertrigger',1); end start(vid); pause(1); set(timer1,'Period',0.5); start(timer1); guidata(hObject,handles); %% timer function function timer1_function(obj,event,hObject,handles,varargin) global vid if ~isempty(vid) if strcmp(get(vid,'running'),'on') trigger(vid); im=getdata(vid); im=imresize(im,0.5); imshow(im,'Parent',handles.axes1); end end % - Executes on button press in stop_button function stop_button_Callback(hObject, eventdata, handles) % hObject handle to stop_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Điều khiển thiết bị dùng cử bàn tay Trang 36/46 global timer1 global vid; if isempty(vid) if strcmp(get(vid,'Running'),'on') stop(timer1); stop(vid); set(hObject,'String','Start') else start(vid); start(timer1); set(hObject,'String','Stop'); end end % - Executes on button press in chupanh_button function chupanh_button_Callback(hObject, eventdata, handles) % hObject handle to chupanh_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global vid global timer1 stop(timer1); if strcmp(get(vid,'Running'),'on') trigger(vid); handles.rgb=getdata(vid); handles.rgb=imresize(handles.rgb,0.5); axes(handles.axes2); imshow(handles.rgb); start(timer1); Điều khiển thiết bị dùng cử bàn tay Trang 37/46 end axes(handles.axes1); guidata(hObject,handles); % - Executes on button press in nhandang_button function nhandang_button_Callback(hObject, eventdata, handles) % hObject handle to nhandang_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global data gray=rgb2gray(handles.rgb); axes(handles.axes2); imshow(gray); bw=im2bw(handles.rgb); axes(handles.axes2); bw=imfill(bw,'holes'); stat=regionprops(bw,'BoundingBox','Area'); n=length(stat); dt=zeros(1,n); for i=1:n dt(i)=stat(i).Area; end p=find(dt==max(dt)); handles.rgb=imcrop(handles.rgb,stat(p).BoundingBox); imshow(handles.rgb); set(handles.kq,'string',''); %pause(0.05); im=imresize(handles.rgb,[data.hang,data.cot]); im=rgb2gray(im); im=double(im); Điều khiển thiết bị dùng cử bàn tay Trang 38/46 T=reshape(im,data.hang*data.cot,1); q=my_pca_trans(T,data.m,data.e); p=my_pca_find(data.q,q,3); s=sprintf('%s',data.Class{p(1)}); set(handles.kq,'string',s); switch data.Class{p(1)} case '1' if strcmp(get(handles.ser_com,'Status'),'open') fwrite(handles.ser_com,100); end case '2' if strcmp(get(handles.ser_com,'Status'),'open') fwrite(handles.ser_com,101); end case '3' if strcmp(get(handles.ser_com,'Status'),'open') fwrite(handles.ser_com,102); end case '4' if strcmp(get(handles.ser_com,'Status'),'open') fwrite(handles.ser_com,103); end case '5' if strcmp(get(handles.ser_com,'Status'),'open') fwrite(handles.ser_com,104); end end % - Executes on button press in taoCSDL_button function taoCSDL_button_Callback(hObject, eventdata, handles) Điều khiển thiết bị dùng cử bàn tay Trang 39/46 % hObject handle to taoCSDL_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) old_dir=cd;% luu thu muc lam viec hien tai new_dir=old_dir; hang=str2double(get(handles.hang,'string')); cot=str2double(get(handles.cot,'string')); if exist('b.mat','file') load b.mat [fNames, new_dir] = uigetfile( {'*.bmp;*.tif;*.jpg;*.tiff;*.png'}, 'Chon Anh', new_dir, 'MultiSelect','on'); else [fNames, new_dir] = uigetfile('*.bmp;*.tif;*.jpg;*.tiff;*.png', 'MultiSelect','on'); end if new_dir~=0 save('b.mat','new_dir'); end cd(new_dir); % chuyen den thu muc duoc chon if iscell(fNames) n=length(fNames); images=cell(1,n); class=cell(1,n); for i=1:n a=imread(fNames{i}); a=imresize(a,[hang,cot]); Điều khiển thiết bị dùng cử bàn tay Trang 40/46 images{i}=a; tam=find(fNames{i}=='-'); s=fNames{i}(tam(1)+1:tam(2)-1); class{i}=s; end end cd(old_dir); % tro ve thu muc lam viec cu T=CreateDatabase(images); [m,e,q]=my_pca(T,'simple'); global data data.m=m; data.e=e; data.q=q; data.T=T; data.hang=hang; data.cot=cot; data.Class=class; function hang_Callback(hObject, eventdata, handles) % hObject handle to hang (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of hang as text % str2double(get(hObject,'String')) returns contents of hang as a double % - Executes during object creation, after setting all properties function hang_CreateFcn(hObject, eventdata, handles) % hObject handle to hang (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows Điều khiển thiết bị dùng cử bàn tay Trang 41/46 % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function cot_Callback(hObject, eventdata, handles) % hObject handle to cot (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of cot as text % str2double(get(hObject,'String')) returns contents of cot as a double % - Executes during object creation, after setting all properties function cot_CreateFcn(hObject, eventdata, handles) % hObject handle to cot (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function kq_Callback(hObject, eventdata, handles) % hObject handle to kq (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of kq as text % str2double(get(hObject,'String')) returns contents of kq as a double % - Executes during object creation, after setting all properties Điều khiển thiết bị dùng cử bàn tay Trang 42/46 function kq_CreateFcn(hObject, eventdata, handles) % hObject handle to kq (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % - Executes on selection change in com_port_list function com_port_list_Callback(hObject, eventdata, handles) % hObject handle to com_port_list (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns com_port_list contents as cell array % contents{get(hObject,'Value')} returns selected item from com_port_list % - Executes during object creation, after setting all properties function com_port_list_CreateFcn(hObject, eventdata, handles) % hObject handle to com_port_list (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end Điều khiển thiết bị dùng cử bàn tay isequal(get(hObject,'BackgroundColor'), Trang 43/46 % - Executes on selection change in baud_rate_list function baud_rate_list_Callback(hObject, eventdata, handles) % hObject handle to baud_rate_list (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns baud_rate_list contents as cell array % contents{get(hObject,'Value')} returns selected item from baud_rate_list % - Executes during object creation, after setting all properties function baud_rate_list_CreateFcn(hObject, eventdata, handles) % hObject handle to baud_rate_list (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % - Executes on button press in connect_button function connect_button_Callback(hObject, eventdata, handles) % hObject handle to connect_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if strcmp(get(hObject,'String'),'Connect') ser_port_n=get(handles.com_port_list,'Value');% lay so so cong com dang chon if (ser_port_n==1) errordlg('This is not a serial port!!'); Điều khiển thiết bị dùng cử bàn tay Trang 44/46 speak('stupid'); else ser_list=get(handles.com_port_list,'String');%lay danh sach ten cac phan ser_port=ser_list{ser_port_n}; ser_com=serial(ser_port); baud_num=get(handles.baud_rate_list,'Value'); baud_string=get(handles.baud_rate_list,'String'); baud=str2double(baud_string{baud_num}); set(ser_com,'baudRate',baud); try set(hObject,'String','Conecting'); pause(0.5); fopen(ser_com); handles.ser_com=ser_com; set(hObject,'String','Disconnect'); catch e errordlg(e.message); set(hObject,'String','Connect'); end end else set(hObject,'String','Connect'); fclose(handles.ser_com); end set(handles.editStatus,'string',handles.ser_com.Status); if(strcmp(handles.ser_com.Status,'open')) msgbox('Da Ket Noi'); else msgbox('Da Ngat Ket Noi'); Điều khiển thiết bị dùng cử bàn tay Trang 45/46 end guidata(hObject, handles); % - Executes on button press in chonanh function chonanh_Callback(hObject, eventdata, handles) % hObject handle to chonanh (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename, pathname] = uigetfile('*','LOAD AN IMAGE'); A=imread(fullfile(pathname, filename)); axes(handles.axes1); imshow(A); handles.rgb= A; guidata(hObject, handles);  Code chương trình điều khiển thiết bị const int ledpin[]={A0,4,2,10,A4}; int recValue; void setup() { Serial.begin(9600); for (int i=0;i0) { recValue=Serial.read(); if (recValue == 100) // If use will send value 100 from MATLAB then LED will turn ON Điều khiển thiết bị dùng cử bàn tay Trang 46/46 { digitalWrite(ledpin[0], !digitalRead(ledpin[0])); } if (recValue == 101) // If use will send value 100 from MATLAB then LED will turn ON { digitalWrite(ledpin[1], !digitalRead(ledpin[1])); } if (recValue == 102) // If use will send value 100 from MATLAB then LED will turn ON { digitalWrite(ledpin[2], !digitalRead(ledpin[2])); } if (recValue == 103) // If use will send value 100 from MATLAB then LED will turn ON { digitalWrite(ledpin[3], !digitalRead(ledpin[3])); } if (recValue == 104) // If use will send value 100 from MATLAB then LED will turn ON { digitalWrite(ledpin[4], !digitalRead(ledpin[4])); } } } Điều khiển thiết bị dùng cử bàn tay ... 6-5: Mơ hình khối điều khiển thiết bị Điều khiển thiết bị dùng cử bàn tay Trang 25/46 Hình 6-6: Mơ hình điều khiển thiết bị dùng cử bàn tay Điều khiển thiết bị dùng cử bàn tay ... chuẩn hóa đầu vào cho ảnh Điều khiển thiết bị dùng cử bàn tay Trang 21/46 CHƯƠNG MƠ HÌNH ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ BÀN TAY 6.1 Khối relay Ta sử dụng khối relay để bật tắt thiết bị Ở ta sử... diện cử bàn tay Nhận diện cử bàn tay phương pháp dùng kỹ thuật máy tính để xác định cử bàn tay mà cụ thể đồ án đếm số ngón tay thể Từ dùng để phát triển ứng dụng điều khiển thiết bị Điều khiển thiết

Ngày đăng: 23/02/2018, 19:44

Từ khóa liên quan

Mục lục

  • DANH MỤC CÁC HÌNH VẼ

  • DANH MỤC CÁC TỪ VIẾT TẮT

  • CHƯƠNG 1. TỔNG QUAN VỀ ĐIỀU KHIỂN THIẾT BỊ DÙNG CỬ CHỈ TAY

    • 1.1 Giới thiệu đề tài

      • 1.1.1 Mục đích nghiên cứu

      • 1.1.2 Phương pháp nghiên cứu

      • 1.2 Định nghĩa về phương pháp nhận diện cử chỉ bàn tay

      • CHƯƠNG 2. CÁC KHÁI NIỆM CƠ BẢN VỀ ẢNH

        • 2.1 Ảnh số và điểm ảnh (pixel)

        • 2.2 Mức xám của ảnh

        • 2.3 Các loại ảnh

          • 2.3.1 Ảnh nhị phân

          • 2.3.2 Ảnh xám

          • 2.3.3 Ảnh màu RGB

          • CHƯƠNG 3. PHƯƠNG PHÁP PHÂN TÍCH THÀNH PHẦN CHÍNH PCA

            • 3.1 Tìm hiểu về PCA

            • 3.2 Thuật toán PCA trong nhận diện cử chỉ bàn tay

              • 3.2.1 Nhận các ảnh bàn tay từ cơ sở dữ liệu – tập ảnh huấn luyện

              • 3.2.2 Tính giá trị vector trung bình

              • 3.2.3 Trừ đi giá trị trung bình

              • 3.2.4 Tính ma trận hiệp biến

              • 3.2.5 Tính các trị riêng và vector đặc trưng của ma trận hiệp biến

              • 3.2.6 Lựa chọn các thành phần và xây dựng vector đặc trưng

              • 3.2.7 Tính giá trị £j

              • CHƯƠNG 4. THIẾT KẾ HỆ THỐNG

                • 4.1 Sơ đồ khối hệ thống

                • 4.2 Khối nhận diện cử chỉ bàn tay

                  • 4.2.1 Xây dựng dữ liệu huấn luyện

Tài liệu cùng người dùng

Tài liệu liên quan