XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG dữ LIỆU THU được từ cảm BIẾN GIA tốc (có code)

78 220 0
XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG dữ LIỆU THU được từ cảm BIẾN GIA tốc (có code)

Đ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

XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG dữ LIỆU THU được từ cảm BIẾN GIA tốc (có code) XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG dữ LIỆU THU được từ cảm BIẾN GIA tốc (có code) XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG dữ LIỆU THU được từ cảm BIẾN GIA tốc (có code) XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG dữ LIỆU THU được từ cảm BIẾN GIA tốc (có code) XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG dữ LIỆU THU được từ cảm BIẾN GIA tốc (có code)

XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC MỤC LỤC DANH MỤC CÁC HÌNH VẼ VI DANH MỤC CÁC BẢNG BIỂU VIII DANH MỤC CÁC TỪ VIẾT TẮT IX CHƯƠNG GIỚI THIỆU ĐỀ TÀI 1.1 ĐẶT VẤN ĐỀ .1 1.2 TÌNH HÌNH NGHIÊN CỨU 1.3 MỤC TIÊU ĐỀ TÀI CHƯƠNG CẢM BIẾN GIA TỐC MEMS VÀ MƠ HÌNH PHẦN CỨNG .7 2.1 CẢM BIẾN GIA TỐC MEMS 2.1.1 Gia tốc gì? 2.1.2 Công nghệ MEMS .8 2.1.3 Cảm biến MEMS .14 2.2 MƠ HÌNH PHẦN CỨNG .19 2.2.1 Cảm biến gia tốc MPU6050 19 2.2.2 ESP8266 20 2.2.3 Nguồn cung cấp 22 2.3 GIA CÔNG THIẾT BỊ 23 2.4 CẤU HÌNH THU THẬP TRUYỀN DỮ LIỆU KHÔNG DÂY 24 CHƯƠNG MƠ HÌNH GIẢI THUẬT 26 3.1 CÁC GIẢI THUẬT PHÂN LOẠI 26 3.1.1 Nhận dạng mẫu .26 3.1.2 Giải thuật mạng nơ ron 27 3.1.3 Giải thuật phân loại Binary tree .28 3.1.4 Giải thuật K-means 29 3.2 MÔ HÌNH GIẢI THUẬT .31 3.2.1 Giai đoạn tiền xử lý 33 3.2.2 Trích xuất đặc trưng 34 3.2.3 Thuật toán phân loại K-means 39 3.2.4 Mơ hình thực nghiệm 41 CHƯƠNG KẾT QUẢ THỰC HIỆN 43 4.1 KẾT QUẢ THI CÔNG THIẾT BỊ 43 4.2 THU THẬP CƠ SỞ DỮ LIỆU 43 4.3 TIỀN XỬ LÝ .44 4.4 TRÍCH ĐẶC TRƯNG 45 4.5 KẾT QUẢ PHÂN LOẠI 50 CHƯƠNG KẾT LUẬN VÀ HƯỚNG PHÁT TRIỂN 51 5.1 KẾT LUẬN .51 5.2 HƯỚNG PHÁT TRIỂN .51 TÀI LIỆU THAM KHẢO 53 PHỤ LỤC A 54 DANH MỤC CÁC HÌNH VẼ HÌNH 2-1: MỐI LIÊN HỆ GIỮA GIA TỐC, VẬN TỐC VÀ ĐỘ DỊCH CHUYỂN HÌNH 2-2: CÁC THÀNH PHẦN CỦA THIẾT BỊ MEMS HÌNH 2-3: QUY TRÌNH CỦA CƠNG NGHỆ VI CƠ KHỐI .11 HÌNH 2-4: QUÁ TRÌNH CHẾ TẠO SỬ DỤNG KỸ THUẬT VI CƠ BỀ MẶT 12 HÌNH 2-5: CHẾ TẠO MEMS THEO CƠNG NGHỆ LIGA [4] 14 HÌNH 2-6: HỆ KHỐI LƯỢNG – LÒ XO ĐƯỢC SỬ DỤNG ĐỂ ĐO GIA TỐC 15 HÌNH 2-7: CÁC DIPOLE ĐIỆN TRONG VẬT LIỆU ÁP ĐIỆN 16 HÌNH 2-8: ĐÁP ỨNG TẦN SỐ CỦA SENSOR GIA TỐC KIỂU ÁP ĐIỆN 17 HÌNH 2-9: ÁP TRỞ LOẠI 18 HÌNH 2-10: ÁP TRỞ LOẠI 18 HÌNH 2-11: MƠ HÌNH HỆ THỐNG 19 HÌNH 2-12: HÌNH ẢNH THỰC TẾ CỦA MPU6050 20 HÌNH 2-13: SƠ ĐỒ CHÂN ESP8266-12 VÀ ÌNH ẢNH THỰC TẾ CỦA ESP8266 21 HÌNH 2-14: PIN SẠC THỰC TẾ 23 HÌNH 2-15: MẠCH LAYOUT 23 HÌNH 2-16: MƠ HÌNH 3D MẠCH 23 HÌNH 2-17: MẠCH SAU KHI HÀN LINH KIỆN .24 HÌNH 2-18: SƠ ĐỒ HỆ THỐNG 24 HÌNH 2-19: KẾT QUẢ KẾT NỐI THIẾT BỊ VÀ TRUYỀN DỮ LIỆU BẰNG ESPLORER 25 HÌNH 3-1: MINH HOẠ VÍ DỤ GIẢI THUẬT BINARY 28 HÌNH 3-2: SƠ ĐỒ THUẬT THỐN K-MEANS 30 HÌNH 3-3: THUẬT TOÁN K-MEANS TRƯỚC VÀ SAU XỬ LÝ 31 HÌNH 3-4: HOẠT ĐỘNG NGHỈ NGƠI 32 HÌNH 3-5: SỰ VẬN ĐỘNG .32 HÌNH 3-6: BIỂU ĐỒ KHỐI CÁC BƯỚC PHÂN LOẠI .33 HÌNH 3-7: BIỂU THỊ CÁC HOẠT ĐỘNG CỦA NGƯỜI 34 HÌNH 3-8: PHƯƠNG PHÁP XÁC ĐỊNH TƯ THẾ CỦA NGƯỜI SỬ DỤNG 37 HÌNH 3-9: BIỂU ĐỒ GIẢI THUẬT CỦA THUẬT TOÁN K-MEANS 40 HÌNH 4-1: DỮ LIỆU TRỤC GIA TỐC ĐƯỢC THỂ HIỆN TRÊN MATLAB 43 HÌNH 4-2: SỰ KHÁC NHAU VỀ TẦN SỐ GIỮA ĐI BỘ VÀ CHẠY BỘ 44 HÌNH 4-3: ĐỘ LỆCH CHUẨN GIA TỐC PHƯƠNG NGANG Y .46 HÌNH 4-4: TẦN SỐ CƠ BẢN CỦA GIA TỐC PHƯƠNG NGANG 46 HÌNH 4-5: ENTROPY TRONG 0.3-5HZ CỦA TỔNG GIA TỐC TRỤC .46 HÌNH 4-6: BIÊN ĐỘ PHỔ CỦA GIA TỐC PHƯƠNG NGANG .47 HÌNH 4-7: NĂNG LƯỢNG PHỔ TRONG 0.3-5 HZ CỦA GIA TỐC PHƯƠNG NGANG 47 HÌNH 4-8: PHÂN BỐ CỦA CÁC ĐẶC TRƯNG ĐỂ PHÂN LOẠI TỐC ĐỘ TRẠNG THÁI ĐI BỘ VÀ CHẠY BỘ 48 HÌNH 4-9: PHÂN BỐ CỦA CÁC ĐẶC TRƯNG ĐỂ PHÂN LOẠI CÁC TRẠNG THÁI NGHỈ/ ĐI/ CHẠY 49 HÌNH 4-10: KẾT QUẢ PHÂN LOẠI HOẠT ĐỘNG CƠ BẢN TỪ MỘT DỮ LIỆU NHIỀU HOẠT ĐỘNG 50 DANH MỤC CÁC BẢNG BI BẢNG 2-1: THÔNG SỐ KỸ THUẬT ESP8266 21 BẢNG 2-2: CÁC LOẠI ESP8266 22 BẢNG 3-1: MÔ TẢ CÁC HOẠT ĐỘNG CỦA NGƯỜI 35 BẢNG 3-2: CÁC HOẠT ĐỘNG ĐƯỢC QUAN SÁT TRONG ĐỀ TÀI: 41 BẢNG 3-3: THÔNG SỐ NGƯỜI THAM GIA XÂY DỰNG CSDL .41 BẢNG 4-1: SỐ LƯỢNG MẪU SỬ DỤNG .43 BẢNG 4-2: BẢNG 17 GIÁ TRỊ ĐẶC TRƯNG ĐƯỢC TRÍCH XUẤT CỦA MỘT NGƯỜI BÌNH THƯỜNG 45 BẢNG 4-3: KẾT QUẢ PHÂN LOẠI HOẠT ĐỘNG CƠ BẢN .50 Y DANH MỤC CÁC TỪ VIẾT TẮT CAD DSP FFT GPS ICs LCD LIGA MEMS MET UDP Computer-aided design Digital Motion Processor Fast Fourier transform Global positioning system Integrated Circuits Liquid crystal display Lithography, Galvanoforming, moulding processes Micro ElectroMechanical Systems Metabolic equivalent of a task User Datagram Protocol Trang 1/73 CHƯƠNG GIỚI THIỆU ĐỀ TÀI 1.1 Đặt vấn đề Cuộc sống ngày phát triển, nhu cầu chăm sóc sức khỏe thân người thân yêu người nâng cao Ngoài vấn đề ăn uống vận động yếu tố quan trọng giúp thúc đẩy q trình chữa bệnh, phòng bệnh, chăm sóc sức khỏe tốt Để có sức khỏe tốt, cần có chế độ chăm sóc tốt việc cấp đầy đủ khoáng chất canxi, vitamin D, MK7 đồng thời cần song hành với chế độ sinh hoạt khoa học, chế độ luyện tập thể dục thể thao đặn Đa số người chọn hình thức bộ, chạy - hình thức thể dục thể thao mang lại nhiều lợi ích sức khỏe cho người tập luyện, ngồi cơng viên, khu vực trống hay chí nhà Một người lực bình thường, ngày nên trì vận động mức km, thể lực tốt tăng lên km Chạy nhiều 6.4 km ngày 45 km tuần, 70 km/tuần 10 km/ngày, đưọc coi vận động cường độ q cao, trì lâu gây bất lợi cho tim mạch [1] Vậy để biết ngày ta vận động bao nhiêu, liệu có q q mức cần thiết sức khỏe Đối với bệnh nhân, đặc biệt bệnh nhân tiểu đường, việc kiểm sốt vận động lại cần thiết Bệnh nhân tiểu đường phát sinh thể không sản xuất đủ insullin (hoocmon điều chỉnh vận động chuyển đường vào tế bào), tế bào chống lại tác động insullin dẫn đến tăng hạ huyết áp bất thường (BG-blood glucoso) Bệnh nhân tiểu đường loại chiếm từ 5-10% số ca mắc bệnh tiểu đường 500 trẻ em 18 tuổi có em bị mắc bệnh [2] Sự hủy hoại tự miễn dịch tế bào β tuyến tụy, dẫn đến insulin không sản sinh Với bệnh tiểu đường loại ta theo dõi mức đường huyết tiêm insulin ngày Các chế độ trị liệu điều trị bệnh tiểu đường thường hướng đến việc trì mức đường huyết liên tục khoảng 90 mg/dl (5mM), mức đường huyết trung bình người bình thường Việc điều trị thực cách đo lượng đường huyết máu thường xuyên người XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 2/73 tiểu đường thiết bị đo mẫu máu lấy đầu ngón tay Khi phát lượng đường huyết vượt ngưỡng cho phép, insulin bơm vào thể để giảm lượng đường huyết Ngược lại lượng đường huyết giảm mức bình thường, người tiểu đường cần bổ sung đường vào thể để tăng lượng đường huyết Còn bệnh nhân tiểu đường loại 2, loại phổ biến chiếm khoảng 90-95% số ca tiểu đường Loại đặc trưng trình sản xuất insulin trì lâu dài, hooc mơn khả điều hòa đường huyết sản xuất trở nên thấp Sự gia tăng bệnh tiểu đường loại ảnh hưởng yếu tố di truyền, béo phì, chế độ dinh dưỡng, vận động độ tuổi Bệnh gây biến chứng phức tạp tổn thương mắt, thận xơ cứng động mạch Việc dùng phương pháp bổ sung insulin vào để giảm đường huyết dần không khả thi Các nhà khoa học đưa lời khuyên nên vận động thể, tập luyện thể dục mức độ vừa phải làm giảm đáng kể lượng mỡ bụng, gan xung quanh tim, yếu tố xem làm tăng nguy mắc bệnh tim mạch, điều quan trọng bệnh nhân tiểu đường loại 2, người bị thừa cân, béo phì Vì gan đóng vai trò việc điều hòa lượng mỡ phân phối thể Vì vậy, việc giảm mỡ gan khối lượng mỡ nội tạng vận động thể thao quan trọng để đảo ngược tác động xấu việc tích tụ mỡ nơi khác tim thành động mạch Từ ta nhận thấy tầm quan trọng việc tập luyện thể thao, vận động sức khỏe người bệnh nhân đái tháo đường, cần có thiết bị hỗ trợ cho ta biết được, cường độ tập luyện, nhịp tim thân tập thể thao hoạt động thông thường ngày giúp ta nắm tình trạng sức khỏe tương đối xác giúp ta điều chỉnh thời gian tập luyện chạy 1.2 Tình hình nghiên cứu Hiện có số nghiên cứu giám sát hoạt động thể cách đo bước chân, có số ứng dụng đưa vào thực tiễn, điển hình ứng dụng đo XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 3/73 khoảng cách di chuyển smartphone Tuy nhiên, cảm biến có mặt hạn chế phân biệt hoạt động chạy, với xe đạp khoảng cách Để phân biệt hoạt động khác liên quan đến mức tiêu thụ lượng đòi hỏi thiết bị giám sát chuyển động tinh vi Mặt khác, tác dụng thiết bị giám sát hoạt động phát huy tác dụng có kết hợp với thiết bị theo dõi dinh dưỡng tiêu thụ thiết bị đo đạc đường huyết Do thiết bị giám sát hoạt động phải siêu nhỏ gọn có khả di động cho phép tích hợp với hệ thống khác Các cảm biến chuyển động vi tiêu chuẩn ngành cơng nghiệp vi mạch silic có kích thước hạn chế khoảng vài mm lựa chọn thích hợp với yêu cầu Các hệ thống vi điện tử MEMS vi điện tử sinh học – BioMEMS có khả thu nhỏ tự động hóa đến mức tích hợp thiết bị đeo đồng hồ hay hệ thống cảm biến cấy ghép Cảm biến chuyển động đơn trục: Máy đo bước ban đầu thiết kế dựa cảm biến chuyển động trục, cho phép giảm thiểu mức tiêu thụ lượng lẫn độ phức tạp lập trình vi điều khiển máy đo bước Đây thiết bị gắn thể thường hơng có bảng điều khiển hình LCD tích hợp hiển thị số bước thực hiện, tích hợp máy nghe nhạc MP3 điện thoại di động ước tính khoảng cách xấp xỉ lượng tiêu thụ Mặc dù thiết bị nhỏ gọn không đắt tiền, sử dụng rộng rãi nghiên cứu y tế thử nghiệm lâm sàng, chúng có hạn chế định Chúng ghi lại số hoạt động giới hạn (chỉ phân biệt hoạt động so với nghỉ ngơi) Hầu hết máy đo bước ước tính lượng thể tiêu thụ cách nhân số bước với hệ số lượng Do thiết bị khơng thể ước tính lượng tiêu thụ nhiều hoạt động khác Gia tốc kế vi giải pháp thay thích hợp đếm bước cho việc đánh giá hoạt động thể chất ngày Các gia tốc đại hệ thống vi điện (MEMS) thiết bị điện thiết kế để đo gia tốc lực hấp dẫn chuyển động tương đối thể Chúng cho phép cảm biến không XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 57/73 end % save trained features filesave=strcat(path,'\','features.mat'); save(filesave,'temp','A_min', 'B_max','m'); Biểu diễn đặc trưng hình, nhiều liệu function train_feat() clc; clear all; close all; addpath('D:\DATN\Matlab') n=15; path='D:\DATN\Matlab\CSDL\Training\rest'; rest(:,1)=feat_pace(path,n); path='D:\DATN\Matlab\CSDL\Training\rest\lying'; n=15; ly(:,1)=feat_pace(path,n); path='D:\DATN\Matlab\CSDL\Training\rest\sitting'; n=15; si(:,1)=feat_pace(path,n); path='D:\DATN\Matlab\CSDL\Training\rest\standing'; n=15; st(:,1)=feat_pace(path,n); n=15; path='D:\DATN\Matlab\CSDL\Training\walk'; walk(:,1)=feat_pace(path,n); n=15; path='D:\DATN\Matlab\CSDL\Training\walk\walk35'; w_35(:,1)=feat_pace(path,n); path='D:\DATN\Matlab\CSDL\Training\walk\walk48'; w_48(:,1)=feat_pace(path,n); n=15; path='D:\DATN\Matlab\CSDL\Training\run'; run(:,1)=feat_pace(path,n); path='D:\DATN\Matlab\CSDL\Training\run\run7'; r_70(:,1)=feat_pace(path,n); path='D:\DATN\Matlab\CSDL\Training\run\run9'; r_91(:,1)=feat_pace(path,n) rest_dist_plot walk_dist_plot rest_walk_run init_basic %=======================Features' values================================= function rest_dist_plot() % function all_plot() XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 58/73 load('D:\DATN\Matlab\CSDL\Training\rest\sitting\features.mat') feat1(:,1)=temp(1,:); feat2(:,1)=temp(2,:); feat3(:,1)=temp(3,:); feat4(:,1)=temp(4,:); feat5(:,1)=temp(5,:); feat6(:,1)=temp(6,:); feat7(:,1)=temp(7,:); feat8(:,1)=temp(8,:); feat9(:,1)=temp(9,:); feat10(:,1)=temp(10,:); feat11(:,1)=temp(11,:); feat12(:,1)=temp(12,:); feat13(:,1)=temp(13,:); feat14(:,1)=temp(14,:); feat15(:,1)=temp(15,:); feat16(:,1)=temp(16,:); feat17(:,1)=temp(17,:); load('D:\DATN\Matlab\CSDL\Training\rest\lying\features.mat') feat1(:,2)=temp(1,:); feat2(:,2)=temp(2,:); feat3(:,2)=temp(3,:); feat4(:,2)=temp(4,:); feat5(:,2)=temp(5,:); feat6(:,2)=temp(6,:); feat7(:,2)=temp(7,:); feat8(:,2)=temp(8,:); feat9(:,2)=temp(9,:); feat10(:,2)=temp(10,:); feat11(:,2)=temp(11,:); feat12(:,2)=temp(12,:); feat13(:,2)=temp(13,:); feat14(:,2)=temp(14,:); feat15(:,2)=temp(15,:); feat16(:,2)=temp(16,:); feat17(:,2)=temp(17,:); load('D:\DATN\Matlab\CSDL\Training\rest\standing\features.mat') feat1(:,3)=temp(1,:); feat2(:,3)=temp(2,:); feat3(:,3)=temp(3,:); feat4(:,3)=temp(4,:); feat5(:,3)=temp(5,:); XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 59/73 feat6(:,3)=temp(6,:); feat7(:,3)=temp(7,:); feat8(:,3)=temp(8,:); feat9(:,3)=temp(9,:); feat10(:,3)=temp(10,:); feat11(:,3)=temp(11,:); feat12(:,3)=temp(12,:); feat13(:,3)=temp(13,:); feat14(:,3)=temp(14,:); feat15(:,3)=temp(15,:); feat16(:,3)=temp(16,:); feat17(:,3)=temp(17,:); %end % ====================plot distribution graph for resting ============================ figure(1) subplot 331 boxplot(feat1,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of mean-x') subplot 332 boxplot(feat2,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of mean-y') subplot 333 boxplot(feat3,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of mean-z') subplot 334 boxplot(feat4,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of std-x') subplot 335 boxplot(feat5,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of std-y') subplot 336 boxplot(feat6,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of std-z') subplot 337 boxplot(feat7,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of TA') subplot 338 XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 60/73 boxplot(feat17,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of Spectral Entropy') figure(2) subplot 331 boxplot(feat8,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of frequency-x') subplot 332 boxplot(feat9,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of frequency-y') subplot 333 boxplot(feat10,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of frequency-z') subplot 334 boxplot(feat11,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of mag-x') subplot 335 boxplot(feat12,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of mag-y') subplot 336 boxplot(feat13,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of mag-z') subplot 337 boxplot(feat14,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of Spectral Energy-x') subplot 338 boxplot(feat15,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of Spectral Energy-y') subplot 339 boxplot(feat16,'orientation','horizontal', 'labels',{'sitting','lying','standing'}) title('Distribution of Spectral Energy-z') %========================================================= === function walk_dist_plot() % function all_plot() load('D:\DATN\Matlab\CSDL\Training\walk\walk35\features.mat') feat1(:,1)=temp(1,:); XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 61/73 feat2(:,1)=temp(2,:); feat3(:,1)=temp(3,:); feat4(:,1)=temp(4,:); feat5(:,1)=temp(5,:); feat6(:,1)=temp(6,:); feat7(:,1)=temp(7,:); feat8(:,1)=temp(8,:); feat9(:,1)=temp(9,:); feat10(:,1)=temp(10,:); feat11(:,1)=temp(11,:); feat12(:,1)=temp(12,:); feat13(:,1)=temp(13,:); feat14(:,1)=temp(14,:); feat15(:,1)=temp(15,:); feat16(:,1)=temp(16,:); feat17(:,1)=temp(17,:); load('D:\DATN\Matlab\CSDL\Training\walk\walk48\features.mat') feat1(:,2)=temp(1,:); feat2(:,2)=temp(2,:); feat3(:,2)=temp(3,:); feat4(:,2)=temp(4,:); feat5(:,2)=temp(5,:); feat6(:,2)=temp(6,:); feat7(:,2)=temp(7,:); feat8(:,2)=temp(8,:); feat9(:,2)=temp(9,:); feat10(:,2)=temp(10,:); feat11(:,2)=temp(11,:); feat12(:,2)=temp(12,:); feat13(:,2)=temp(13,:); feat14(:,2)=temp(14,:); feat15(:,2)=temp(15,:); feat16(:,2)=temp(16,:); feat17(:,2)=temp(17,:); load('D:\DATN\Matlab\CSDL\Training\run\run7\features.mat') feat1(:,3)=temp(1,:); feat2(:,3)=temp(2,:); feat3(:,3)=temp(3,:); feat4(:,3)=temp(4,:); feat5(:,3)=temp(5,:); feat6(:,3)=temp(6,:); XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 62/73 feat7(:,3)=temp(7,:); feat8(:,3)=temp(8,:); feat9(:,3)=temp(9,:); feat10(:,3)=temp(10,:); feat11(:,3)=temp(11,:); feat12(:,3)=temp(12,:); feat13(:,3)=temp(13,:); feat14(:,3)=temp(14,:); feat15(:,3)=temp(15,:); feat16(:,3)=temp(16,:); feat17(:,3)=temp(17,:); load('D:\DATN\Matlab\CSDL\Training\run\run9\features.mat') feat1(:,4)=temp(1,:); feat2(:,4)=temp(2,:); feat3(:,4)=temp(3,:); feat4(:,4)=temp(4,:); feat5(:,4)=temp(5,:); feat6(:,4)=temp(6,:); feat7(:,4)=temp(7,:); feat8(:,4)=temp(8,:); feat9(:,4)=temp(9,:); feat10(:,4)=temp(10,:); feat11(:,4)=temp(11,:); feat12(:,4)=temp(12,:); feat13(:,4)=temp(13,:); feat14(:,4)=temp(14,:); feat15(:,4)=temp(15,:); feat16(:,4)=temp(16,:); feat17(:,4)=temp(17,:); %end % ====================plot distribution graph for walking and running ============================ figure(3) subplot 331 boxplot(feat1,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of mean-x') subplot 332 boxplot(feat2,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of mean-y') subplot 333 boxplot(feat3,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of mean-z') XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 63/73 subplot 334 boxplot(feat4,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of std-x') subplot 335 boxplot(feat5,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of std-y') subplot 336 boxplot(feat6,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of std-z') subplot 337 boxplot(feat7,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of TA') subplot 338 boxplot(feat17,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of Spectral Entropy') figure(4) subplot 331 boxplot(feat8,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of frequency-x') subplot 332 boxplot(feat9,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of frequency-y') subplot 333 boxplot(feat10,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of frequency-z') subplot 334 boxplot(feat11,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of mag-x') subplot 335 boxplot(feat12,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of mag-y') subplot 336 boxplot(feat13,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of mag-z') XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 64/73 subplot 337 boxplot(feat14,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of Spectral Energy-x') subplot 338 boxplot(feat15,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of Spectral Energy-y') subplot 339 boxplot(feat16,'orientation','horizontal', 'labels',{'walking35','walking48','running7', 'running91'}) title('Distribution of Spectral Energy-z') % end %=======================Features' values================================= function rest_walk_run() % function all_plot() load('D:\DATN\Matlab\CSDL\Training\rest\features.mat') feat1(:,1)=temp(1,:); feat2(:,1)=temp(2,:); feat3(:,1)=temp(3,:); feat4(:,1)=temp(4,:); feat5(:,1)=temp(5,:); feat6(:,1)=temp(6,:); feat7(:,1)=temp(7,:); feat8(:,1)=temp(8,:); feat9(:,1)=temp(9,:); feat10(:,1)=temp(10,:); feat11(:,1)=temp(11,:); feat12(:,1)=temp(12,:); feat13(:,1)=temp(13,:); feat14(:,1)=temp(14,:); feat15(:,1)=temp(15,:); feat16(:,1)=temp(16,:); feat17(:,1)=temp(17,:); load('D:\DATN\Matlab\CSDL\Training\walk\features.mat') feat1(:,2)=temp(1,:); feat2(:,2)=temp(2,:); feat3(:,2)=temp(3,:); feat4(:,2)=temp(4,:); feat5(:,2)=temp(5,:); feat6(:,2)=temp(6,:); feat7(:,2)=temp(7,:); feat8(:,2)=temp(8,:); XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 65/73 feat9(:,2)=temp(9,:); feat10(:,2)=temp(10,:); feat11(:,2)=temp(11,:); feat12(:,2)=temp(12,:); feat13(:,2)=temp(13,:); feat14(:,2)=temp(14,:); feat15(:,2)=temp(15,:); feat16(:,2)=temp(16,:); feat17(:,2)=temp(17,:); load('D:\DATN\Matlab\CSDL\Training\run\features.mat') feat1(:,3)=temp(1,:); feat2(:,3)=temp(2,:); feat3(:,3)=temp(3,:); feat4(:,3)=temp(4,:); feat5(:,3)=temp(5,:); feat6(:,3)=temp(6,:); feat7(:,3)=temp(7,:); feat8(:,3)=temp(8,:); feat9(:,3)=temp(9,:); feat10(:,3)=temp(10,:); feat11(:,3)=temp(11,:); feat12(:,3)=temp(12,:); feat13(:,3)=temp(13,:); feat14(:,3)=temp(14,:); feat15(:,3)=temp(15,:); feat16(:,3)=temp(16,:); feat17(:,3)=temp(17,:); %end % ====================plot distribution graph for resting ============================ figure(5) subplot 331 boxplot(feat1,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of mean-x') subplot 332 boxplot(feat2,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of mean-y') subplot 333 boxplot(feat3,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of mean-z') XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 66/73 subplot 334 boxplot(feat4,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of std-x') subplot 335 boxplot(feat5,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of std-y') subplot 336 boxplot(feat6,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of std-z') subplot 337 boxplot(feat7,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of TA') subplot 338 boxplot(feat17,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of Spectral Entropy') figure(6) subplot 331 boxplot(feat8,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of frequency-x') subplot 332 boxplot(feat9,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of frequency-y') subplot 333 boxplot(feat10,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of frequency-z') subplot 334 boxplot(feat11,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of mag-x') subplot 335 boxplot(feat12,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of mag-y') subplot 336 boxplot(feat13,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of mag-z') XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 67/73 subplot 337 boxplot(feat14,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of Spectral Energy-x') subplot 338 boxplot(feat15,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of Spectral Energy-y') subplot 339 boxplot(feat16,'orientation','horizontal', 'labels',{'resting','walking','running'}) title('Distribution of Spectral Energy-z') % ======================load features as centroids======================== function init_basic() load('D:\DATN\Matlab\CSDL\Training\rest\features.mat') initcenter(1,:)=m; init_basic(1,:)=[m(5);m(9);m(17);m(12);m(15)]; load('D:\DATN\Matlab\CSDL\Training\walk\features.mat') initcenter(2,:)=m; init_basic(2,:)=[m(5);m(9);m(17);m(12);m(15)]; load('D:\DATN\Matlab\CSDL\Training\run\features.mat') initcenter(3,:)=m; init_basic(3,:)=[m(5);m(9);m(17);m(12);m(15)] Phân loại hoạt động nghỉ/ đi/ chạy function class_basic(filename) % clc; % clear all; % close all; %filename='D:\DATN\Matlab\CSDL\Testing\Others\standtoruntostand.mat'; load(filename); [r c]=size(a); Fs = 30; % Sampling frequency NFFT = 2^nextpow2(r); % Next power of from length of y % NFFT=2^9; Ax = fft(a(:,1),NFFT)/r; Ay = fft(a(:,2),NFFT)/r; Az = fft(a(:,3),NFFT)/r; f = Fs/2*linspace(0,1,NFFT/2+1); mAx=abs(Ax(1:NFFT/2+1)); mAy=abs(Ay(1:NFFT/2+1)); mAz=abs(Az(1:NFFT/2+1)); if rem(NFFT, 2) % odd nfft excludes Nyquist point XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 68/73 mAx(2:end) = mAx(2:end)*2; mAy(2:end) = mAy(2:end)*2; mAz(2:end) = mAz(2:end)*2; else mAx(2:end -1) = mAx(2:end -1)*2; mAy(2:end -1) = mAy(2:end -1)*2; mAz(2:end -1) = mAz(2:end -1)*2; end % % % % % % % % % Plot single-sided amplitude spectrum figure(1) subplot(2,1,2) plot(f,mAx,f,mAy,f,mAz) axis([0 1.5]); title(strcat('Frequency Spectrum of raw signals')) xlabel('Frequency (Hz)') ylabel('|A(f)|') legend('x','y','z'); % cut the data to n+1 segments -[r c]=size(a); % calculate the number of segment, 5s for one segment seg_t=10; Fs=30; seg_n=seg_t*Fs; %500 for t=10s n=floor(r/seg_n); % calculate the features -% pattern=feat_extr(filename); % features(1,:)=pattern; % % feat_3(:,1)=features(:,5); % feat_3(:,2)=features(:,11); % feat_3(:,3)=features(:,12); % feat_3(:,4)=features(:,15); % feat_3(:,5)=features(:,17) for i=1:n seg_name=strcat('seg_',num2str(i),'.mat'); % s=a((i-1)*seg_n+1:i*seg_n+1,:); % t_seg=t(:,(i-1)*seg_n+1:i*seg_n+1); s=a((i-1)*seg_n+1:i*seg_n,:); t_seg=t((i-1)*seg_n+1:i*seg_n,:); save(seg_name,'s','t_seg'); % pattern=pattern_extract(seg_name); pattern=feat_extrs(seg_name); save(seg_name,'s','t_seg', 'pattern'); features(i,:)=pattern; end m=n; if (r-n*seg_n)>36 m=n+1; seg_name=strcat('seg_',num2str(m),'.mat'); s=a(n*seg_n+1:r,:); t_seg=t(n*seg_n+1:r,:); save(seg_name,'s','t_seg'); pattern=feat_extrs(seg_name); save(seg_name,'s','t_seg', 'pattern'); features(m,:)=pattern; end XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 69/73 % feat_3(:,1)=features(:,5); feat_3(:,2)=features(:,9); feat_3(:,3)=features(:,17); feat_3(:,4)=features(:,12); feat_3(:,5)=features(:,15); % classification algorithm -[cidx, ctrs] = kmeans(feat_3, 3,'Distance', 'sqEuclidean', 'MaxIter', 1000, 'EmptyAction','drop'); % calculate the features -% pattern=feat_extr(filename); % features(1,:)=pattern; % % feat_3(:,1)=features(:,5); % feat_3(:,2)=features(:,11); % feat_3(:,3)=features(:,12); % feat_3(:,4)=features(:,15); % feat_3(:,5)=features(:,17) for i=1:n seg_name=strcat('seg_',num2str(i),'.mat'); % s=a((i-1)*seg_n+1:i*seg_n+1,:); % t_seg=t(:,(i-1)*seg_n+1:i*seg_n+1); s=a((i-1)*seg_n+1:i*seg_n,:); t_seg=t((i-1)*seg_n+1:i*seg_n,:); save(seg_name,'s','t_seg'); % pattern=pattern_extract(seg_name); pattern=feat_extrs(seg_name); save(seg_name,'s','t_seg', 'pattern'); features(i,:)=pattern; end m=n; if (r-n*seg_n)>36 m=n+1; seg_name=strcat('seg_',num2str(m),'.mat'); s=a(n*seg_n+1:r,:); t_seg=t(n*seg_n+1:r,:); save(seg_name,'s','t_seg'); pattern=feat_extrs(seg_name); save(seg_name,'s','t_seg', 'pattern'); features(m,:)=pattern; end % feat_3(:,1)=features(:,5); feat_3(:,2)=features(:,9); feat_3(:,3)=features(:,17); feat_3(:,4)=features(:,12); feat_3(:,5)=features(:,15); % classification algorithm -[cidx, ctrs] = kmeans(feat_3, 3,'Distance', 'sqEuclidean', 'MaxIter', 1000, 'EmptyAction','drop'); load init_all.mat; init_basic; i1=find(cidx==1); if length(i1)~=0 for i=1:length(i1) XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 70/73 feat1(i,:)=feat_3(i1(i),:); end end [r c]=size(feat1); r_plus=3-r; for i=1:r_plus; feat1(r+i,:)=feat1(1,:); i=i+1; end [cidx1, ctrs1] = kmeans(feat1, 3,'Distance', 'sqEuclidean', 'MaxIter', 1, 'EmptyAction','drop','start',init_basic(1:3,:)); i11=find(cidx1==1); i12=find(cidx1==2); i13=find(cidx1==3); i1_e=[length(i11);length(i12);length(i13)]; [Y,I]=max(i1_e); label(1,:)=[I;length(i1)]; % i2=find(cidx==2); if length(i2)~=0 for i=1:length(i2) feat2(i,:)=feat_3(i2(i),:); end end [r c]=size(feat2); r_plus=3-r; for i=1:r_plus feat2(r+i,:)=feat2(1,:); i=i+1; end [cidx2, ctrs2] = kmeans(feat2, 3,'Distance', 'sqEuclidean', 'MaxIter', 1, 'EmptyAction','drop','start',init_basic(1:3,:)); i21=find(cidx2==1); i22=find(cidx2==2); i23=find(cidx2==3); i2_e=[length(i21);length(i22);length(i23)]; [Y,I]=max(i2_e); label(2,:)=[I;;length(i2)]; % -i3=find(cidx==3); if length(i3)~=0 for i=1:length(i3) feat3(i,:)=feat_3(i3(i),:); end end [r c]=size(feat3); r_plus=3-r; for i=1:r_plus feat3(r+i,:)=feat3(1,:); i=i+1; end [cidx3, ctrs3] = kmeans(feat3, 3,'Distance', 'sqEuclidean', 'MaxIter', 1, 'EmptyAction','drop','start',init_basic(1:3,:)); i31=find(cidx3==1); XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 71/73 i32=find(cidx3==2); i33=find(cidx3==3); i3_e=[length(i31);length(i32);length(i33)]; [Y,I]=max(i3_e); label(3,:)=[I;length(i3)]; figure() for i=1:m seg_name=strcat('seg_',num2str(i),'.mat'); load(seg_name); % label(cidx(i),1) if label(cidx(i),1)==1 plot(t_seg,s(:,2),'r-') % name='rest'; % text(t_seg(2),-0.5,name); elseif label(cidx(i),1)==2 plot(t_seg,s(:,2),'g-') % name='walk'; % text(t_seg(2),0,name); elseif label(cidx(i),1)==3 plot(t_seg,s(:,2),'b-') % name='run'; % text(t_seg(2),0.5,name); hold on end hold on xlabel('Time [s]') ylabel('Acceleration [g]') title(strcat('Classification results using k-means clustering')) end save('results.mat','cidx1','cidx2','cidx3') Phân loại hoạt động nghỉ/ đi/ chạy chuỗi mẫu clc; clear all; close all; n=9; % path='D:\DATN\Matlab\CSDL\Testing\rest'; % path='D:\DATN\Matlab\CSDL\Testing\walk'; path='D:\DATN\Matlab\CSDL\Testing\run'; addpath(path) for i=1:n filename=strcat(path,'\',num2str(i),'.mat'); class_basic(filename); load ('results.mat') cidx1 cidx2 cidx3 end XÂY DỰNG GIẢI THUẬT PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC ... phân loại XÂY DỰNG GIẢI THU T PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 7/73 CHƯƠNG CẢM BIẾN GIA TỐC MEMS VÀ MÔ HÌNH PHẦN CỨNG 1.4 Cảm biến gia tốc MEMS 1.1.1 Gia tốc. .. gia tốc, vận tốc độ dịch chuyển XÂY DỰNG GIẢI THU T PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 8/73 Để máy hiểu thơng số gia tốc sử dụng tốn tự động hóa, ta cần cảm biến. .. định đo gia tốc chiều có mối quan hệ phức tạp điện áp lối biên độ gia tốc tần số Cảm XÂY DỰNG GIẢI THU T PHÂN LOẠI HOẠT ĐỘNG DÙNG DỮ LIỆU THU ĐƯỢC TỪ CẢM BIẾN GIA TỐC Trang 17/73 biến gia tốc kiểu

Ngày đăng: 27/02/2018, 10:43

Mục lục

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

    DANH MỤC CÁC BẢNG BI

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

    CHƯƠNG 1. GIỚI THIỆU ĐỀ TÀI

    1.2 Tình hình nghiên cứu

    1.3 Mục tiêu đề tài

    CHƯƠNG 2. CẢM BIẾN GIA TỐC MEMS VÀ MÔ HÌNH PHẦN CỨNG

    1.4 Cảm biến gia tốc MEMS

    1.1.1 Gia tốc là gì?

    1.5 Mô hình phần cứng

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

  • Đang cập nhật ...