(Đồ án hcmute) nghiên cứu, thiết kế và thi công cửa nhận dạng khuôn mặt và điều khiển, giám sát các thiết bị trong nhà

114 3 0
(Đồ án hcmute) nghiên cứu, thiết kế và thi công cửa nhận dạng khuôn mặt và điều khiển, giám sát các thiết bị trong nhà

Đ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

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH ĐỒ ÁN TỐT NGHIỆP NGÀNH KỸ THUẬT ĐIỆN TỬ - TRUYỀN THÔNG NGHIÊN CỨU, THIẾT KẾ VÀ THI CÔNG CỬA NHẬN DẠNG KHUÔN MẶT VÀ ĐIỀU KHIỂN, GIÁM SÁT CÁC THIẾT BỊ TRONG NHÀ GVHD: NGUYỄN ĐÌNH PHÚ SVTH: PHẠM QUỐC BẢO MSSV:15141101 SVTH: VÕ VĂN THÀNH MSSV:15141283 SKL 0 8 Tp Hồ Chí Minh, tháng 6/2019 an BỘ GIÁO DỤC & ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT TP HỒ CHÍ MINH KHOA ĐIỆN – ĐIỆN TỬ BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH ĐỒ ÁN TỐT NGHIỆP NGÀNH CÔNG NGHỆ KỸ THUẬT ĐIỆN TỬ TRUYỀN THÔNG ĐỀ TÀI: NGHIÊN CỨU, THIẾT KẾ VÀ THI CÔNG CỬA NHẬN DẠNG KHUÔN MẶT VÀ ĐIỀU KHIỂN, GIÁM SÁT CÁC THIẾT BỊ TRONG NHÀ GVHD: ThS NGUYỄN ĐÌNH PHÚ SVTH: PHẠM QUỐC BẢO 15141101 VÕ VĂN THÀNH 15141283 Tp Hồ Chí Minh – 06/2019 an BỘ GIÁO DỤC & ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT TP HỒ CHÍ MINH KHOA ĐIỆN – ĐIỆN TỬ BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH - ĐỒ ÁN TỐT NGHIỆP NGÀNH CÔNG NGHỆ KỸ THUẬT ĐIỆN TỬ TRUYỀN THÔNG ĐỀ TÀI: NGHIÊN CỨU, THIẾT KẾ VÀ THI CÔNG CỬA NHẬN DẠNG KHUÔN MẶT VÀ ĐIỀU KHIỂN, GIÁM SÁT THIẾT BỊ TRONG NHÀ GVHD: ThS NGUYỄN ĐÌNH PHÚ SVTH: PHẠM QUỐC BẢO 15141101 VÕ VĂN THÀNH 15141283 Tp Hồ Chí Minh – 06/2019 an TRƯỜNG ĐH SPKT TP HỒ CHÍ MINH KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM ĐỘC LẬP - TỰ DO - HẠNH PHÚC o0o -Tp HCM, ngày tháng năm 2019 NHIỆM VỤ ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên: Phạm Quốc Bảo MSSV: 15141101 Võ Văn Thành MSSV: 15141283 Chuyên ngành: Kỹ thuật điện tử - truyền thông Mã ngành: 141 Hệ đào tạo: Đại học quy Mã hệ: Khóa: 2015 Lớp: 15141DT2A I TÊN ĐỀ TÀI: NGHIÊN CỨU, THIẾT KẾ VÀ THI CÔNG CỬA NHẬN DẠNG KHUÔN MẶT VÀ ĐIỀU KHIỂN, GIÁM SÁT THIẾT BỊ TRONG NHÀ II NHIỆM VỤ Các số liệu ban đầu: (ghi thông số, tập tài liệu tín hiệu, hình ảnh…) Nội dung thực hiện: (ghi nội dung cần thực phần tổng quan) III NGÀY GIAO NHIỆM VỤ: IV NGÀY HOÀN THÀNH NHIỆM VỤ: V HỌ VÀ TÊN CÁN BỘ HƯỚNG DẪN: ThS Nguyễn Đình Phú i an TRƯỜNG ĐH SPKT TP HỒ CHÍ MINH KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM ĐỘC LẬP - TỰ DO - HẠNH PHÚC o0o -Tp HCM, ngày tháng năm 2019 LỊCH TRÌNH THỰC HIỆN ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên 1: Phạm Quốc Bảo Lớp: 15141DT2A MSSV: 15141101 Họ tên sinh viên 2: Võ Văn Thành Lớp: 15141DT1B MSSV: 15141283 Tên đề tài: NGHIÊN CỨU, THIẾT KẾ VÀ THI CÔNG CỬA NHẬN DẠNG KHUÔN MẶT VÀ ĐIỀU KHIỂN, GIÁM SÁT THIẾT BỊ TRONG NHÀ Tuần/ngày Tuần (18/2 – 24/2) Tuần (25/2 – 3/3) Tuần (4/3 – 10/3) Nội dung Xác nhận GVHD - Gặp giáo viên hướng dẫn - Chọn đề tài - Báo cáo GVHD - Viết đề cương chi tiết cho đồ án - Báo cáo GVHD - Trình bày phướng án thực đề tài - Phân chia công việc cho thành viên Tuần (11/3 – 17/3) Tuần (18/3 – 24/3) Tuần (25/3 – 31/3) - Báo cáo GVHD - Tìm hiểu Raspberry Pi 3b xử lý ảnh - Báo cáo GVHD - Thiết kế sơ đồ nguyên lý toàn mạch - Lập danh sách, mua linh kiện cần thiết - Tìm hiểu giao tiếp ngoại vi với STM32F407 ii an Tuần (1/4 - 7/4) - Báo cáo GVHD - Kết nối khối ngõ ra, hiển thị thông tin đo đạc hình Tuần (8/4 – 14/4) - Báo cáo GVHD - Tìm hiểu giao thức HTTP thiết kế webserver Tuần (15/4 – 21/4) Tuần 10 (22/4 – 28/4) Tuần 11 (29/4 – 5/5) Tuần 12 (6/5 – 12/5) Tuần 13 (13/5 – 19/5) - Báo cáo GVHD - Tiến hành thiết kế giao diện web app - Báo cáo GVHD - Viết chương trình cho tồn hệ thống - Báo cáo GVHD - Vẽ mạch PCB, hàn mạch - Báo cáo GVHD - Thi công hộp đựng - Báo cáo GVHD - Lắp mạch thiết bị liên quan vào hộp - Chạy thử nghiệm Tuần 14 (20/5 – 26/5) Tuần 15 (27/5 – 2/6) Tuần 16 - Báo cáo GVHD - Cân chỉnh, tối ưu sản phẩm - Báo cáo GVHD - Chỉnh sửa hoàn thiện báo cáo - Bảo vệ ĐATN (18/6 – 22/6) GV HƯỚNG DẪN (Ký ghi rõ họ tên) iii an LỜI CAM ĐOAN Đề tài nhóm tự thực dựa vào số tài liệu trước khơng chép từ tài liệu hay cơng trình có trước Người thực đề tài Phạm Quốc Bảo Võ Văn Thành iv an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha LỜI CẢM ƠN Lời đầu tiên, nhóm đề tài xin gởi lời cảm ơn chân thành đến Thầy Nguyễn Đình Phú - giảng viên khoa Điện-Điện tử, Trường ĐH Sư phạm Kỹ thuật Tp HCM, theo sát hỗ trợ hướng dẫn nhóm cách chi tiết trình thực đề tài Thầy ln hỗ trợ hết mình, giải đáp thắc mắc, sai sót gợi ý phương án thực cho khả thi dễ tiếp cận Nhóm xin gửi lời cảm ơn đến q thầy(cơ) khoa Điện-Điện tử tận tình giải đáp thắc mắc, nguyện vọng trình thực đề tài nhóm Sự hỗ trợ quý thầy(cơ) đóng góp phần khơng nhỏ vào thành cơng ngày hơm Nhóm đề tài xin cảm ơn bạn sinh viên khoa Điện-Điện tử nhiệt tình giúp đỡ, hỗ trợ nhóm, đặc biệt tập thể lớp 1514DT2A 15141DT1B Những đóng góp bạn ln nhóm tiếp nhận xem xét kĩ lưỡng Cuối cùng, nhóm xin cảm ơn chân thành sâu sắc đến Cha, Mẹ - người bên cạnh hỗ trợ tài tinh thần suốt năm tháng qua Thành công đề tài ngày phần đóng góp to lớn người Một lần nữa, nhóm xin gởi lời cảm ơn chân thành đến quý thầy cô, bạn bè quý phụ huynh hỗ trợ nhóm thực đề tài hồn chỉnh Xin chân thành cảm ơn! Người thực đề tài Phạm Quốc Bảo Võ Văn Thành v an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha MỤC LỤC NHIỆM VỤ ĐỒ ÁN TỐT NGHIỆP i LỊCH TRÌNH THỰC HIỆN ĐỒ ÁN TỐT NGHIỆP ii LỜI CAM ĐOAN iv LỜI CẢM ƠN v MỤC LỤC vi DANH MỤC HÌNH ix DANH MỤC BẢNG xiii TÓM TẮT .xiv CHƯƠNG 1: TỔNG QUAN 1.1 ĐẶT VẤN ĐỀ 1.2 MỤC TIÊU .2 1.3 NỘI DUNG NGHIÊN CỨU 1.4 GIỚI HẠN 1.5 BỐ CỤC CHƯƠNG 2: CƠ SỞ LÝ THUYẾT 2.1 TỔNG QUAN VỀ XỬ LÝ ẢNH .4 2.1.1 Giới thiệu xử lý ảnh 2.1.2 Những vấn đề xử lý ảnh 2.2 PHƯƠNG PHÁP NHẬN DẠNG KHUÔN MẶT 2.2.1 Phương pháp HOG (Histogram of Oriented Gradient) .7 2.2.2 Phương pháp SVM (Support Vector Machine algorithm) 11 2.3 NGÔN NGỮ PYTHON VÀ THƯ VIỆN OPENCV 12 2.3.1 Ngôn ngữ Python 12 2.3.2 Thư viện Open CV 13 2.4 GIỚI THIỆU CƠ SỞ DỮ LIỆU SQL 14 2.5 THƯ VIỆN DLIB 15 2.6 TỔNG QUAN VỀ IoT 17 2.6.1 Tổng quan 17 2.6.2 Đặc tính 18 vi an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha CHƯƠNG 3: TÍNH TỐN VÀ THIẾT KẾ HỆ THỐNG 19 3.1 THIẾT KẾ SƠ ĐỒ KHỐI 19 3.2 RASPBERRY PI MODEL B 20 3.3 STM32F407VG 22 3.3.1 Bộ điều khiển reset 24 3.3.2 Xung clock 25 3.3.3 Gpio 26 3.4 WEBCAM LOGITECH 31 3.5 MÀN HÌNH CẢM ỨNG NEXTION 32 3.6 NODEMCU ESP8266 33 3.7 BÀN PHÍM MA TRẬN 35 3.8 SƠ ĐỒ NGUYÊN LÝ TOÀN MẠCH 36 CHƯƠNG 4: THI CÔNG HỆ THỐNG 38 4.1 GIỚI THIỆU 38 4.2 THI CÔNG HỆ THỐNG 38 4.2.1 Thi công board mạch 38 4.2.2 Lắp ráp kiểm tra 42 4.3 ĐĨNG GĨI VÀ THI CƠNG MƠ HÌNH 44 4.4 LẬP TRÌNH HỆ THỐNG 44 4.4.1 Lưu đồ giải thuật 44 4.4.2 Giới thiệu hệ điều hành Raspbian 50 4.4.3 Giới thiệu phần mềm Android 53 4.3.4 Trình biên dịch Keil µVision 59 4.3.5 Phần mềm viết giao diện hình Nextion Editor 66 4.3.6 Giới thiệu Cpanel 67 4.3.7 Giới thiệu PHPMyAdmin 74 4.3.8 Giới thiệu ngôn ngữ PHP 77 CHƯƠNG 5: KẾT QUẢ – NHẬN XÉT – ĐÁNH GIÁ 80 5.1 KẾT QUẢ 80 5.2 NHẬN XÉT, ĐÁNH GIÁ 84 vii an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP Giao diện website điều khiển (hình 5.5) gồm nút điều khiển bật đèn, tắt đèn trạng thái đèn Website truy cập từ nơi đâu thiết bị có Internet, Wifi Hình 5.4: Nhật kí người vào App Android Hình 5.5: Nhật kí người vào web BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 83 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP Ứng dụng Android (hình 5.6) ứng dụng web (hình 5.7) thiết kế với giao diện đơn giản để hiển thị danh sách người mở gần mà hệ thống nhận dạng Ngồi hệ thống nhận dạng cịn lưu lại hình ảnh người khơng nhận dạng được, với việc lưu video ngày lưu trữ bên USB 32GB tất hãng, tự động làm dung lượng lưu trữ lại nhỏ 100MB.Nhóm cịn cung cấp giải pháp tìm kiếm người vào nhà thông qua khoảng thời gian biết trước 5.2 NHẬN XÉT, ĐÁNH GIÁ Nhìn chung kết nhóm đạt mục tiêu ban đầu mà nhóm đề thực đồ án Trên sở nghiên cứu tổng quan IoT với trung tâm điều khiển ARM STM32F407VG, chúng em xây dựng thành cơng hệ thống có tính thực nghiệm cao, điều khiển linh hoạt thiết bị nhà, thông qua Webserver, ứng dụng điện thoại Android, cung cấp giao diện mẻ với nhiều tính tiện lợi cho người sử dụng Về độ ổn định, tắt mở nguồn 10 lần mạch chạy Bên cạnh đó, mạch tối ưu kích thước độ thẩm mĩ Tuy nhiên số lỗi nhận dạng ảnh phải cần có đủ ánh sáng tốc độ xửa lý phụ thuộc vào tốc độ wifi BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 84 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP CHƯƠNG 6: KẾT LUẬN VÀ HƯỚNG PHÁT TRIỂN 6.1 KẾT LUẬN Sau thời gian nghiên cứu làm việc chăm nhóm thành cơng sau:  Nhận dạng chủ nhà nhờ hệ thống liệu có sẵn từ trước mơi trường đầy đủ ánh sáng  Điều khiển hệ thống thông qua Webserver, Ứng dụng điện thoại Android, hình cảm ứng  Giám sát hoạt động ngõ giúp cảnh báo sớm lỗi xảy  Chức đăng nhập giúp tránh trường hợp người nhà điều khiển thiết bị 6.2 HƯỚNG PHÁT TRIỂN  Sử dụng sóng RF để mở rộng quy mô điều khiển  Tăng cường khả nhận diện chủ nhà vào buổi tối  Tích hợp hệ thống khoá cửa để chủ nhà vào nhà dễ dàng  Thương mại hoá sản phẩm làm  Viết ứng dụng nạp file thư viện hình ảnh qua internet giúp người dùng thuận tiện việc cập nhật thành viên gia đình BỘ MƠN ĐIỆN TỬ CƠNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 85 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP TÀI LIỆU THAM KHẢO [1] https://www.pyimagesearch.com/ [2] https://viblo.asia/p/tim-hieu-ve-hoghistogram-of-oriented-gradientsm68Z0wL6KkG [3] https://viblo.asia/p/support-vector-machine-trong-hoc-may-mot-cai-nhin-dongian-hon-XQZkxoQmewA [4] Internet of Things (IoT): cho người mớ i bắ t đầ u” https://iotmakervn.github.io/iot-starter-book/#_esp8266 [5] https://embeddedsystemengineering.blogspot.com/2015/07/stm32f4-discoverytutorial-7-adc.html [6] https://www.w3schools.com/php/ [7] https://www.w3schools.com/bootstrap/ [8] https://www.w3schools.com/sql/ “Smartconfig vớ i ESP8266” [9] https://hocarm.org/smartconfig-voi-esp8266/ [10] “ESP8266 Datasheet” https://www.espressif.com/sites/default/files/documentation/0a esp8266ex_datasheet_en.pdf [11] (Reference manual) https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6 d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translatio ns/en.DM00031020.pdf [12] “Hư ớng dẫn sử du ̣ng MySQL trê n hosting cPanel” https://vnso.vn/huong-dansu-dung-mysql-tren-hosting-cpanel/ [13] “Tê n miề n (domain) là gı̀?” https://siengvan.com/ten-mien-domain-la-gi/ [14] “HOST LÀ GÌ? HOST NÀO ĐỂ DÙNG ĐƯ ƠC ̣ WORDPRESS?” https://thachpham.com/hosting-domain/host-la-gi.html BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 86 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP Sá ch tham khả o [15] Nguyễn Đı̀nh Phú , “Giá o trı̀nh vi xử lý ”, NXB Trư ờng ĐH Sư Pha ̣m Kỹ Thuật Tp.HCM, 2016 [16] Nguyễn Đình Phú – Phan Vân Hồn – Trương Ngo ̣c Anh, “Giá o trı̀nh thực hà nh vi điề u khiể n PIC”, NXB Trường ĐH Sư Pha ̣m Kỹ Thuật Tp.HCM, 08/2017 BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 87 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP PHỤ LỤC Chương trình xử lý ảnh – nhận diện khuôn mặt Raspberry Pi # Title: python3 pi_face_recognition.py # import the necessary packages from imutils.video import VideoStream import face_recognition import imutils import pickle import os import time import cv2 from datetime import datetime import shutil import RPi.GPIO as GPIO import socket import smtplib import mysql.connector from mysql.connector import Error from mysql.connector import errorcode from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from pad4pi import rpi_gpio import json ## Get Ip and send email s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) s.connect(('google.com',0)) ipAdress = s.getsockname()[0] s.close() to = 'baopq.spkt@gmail.com' fromemail = 'baopq.spkt@gmail.com' your_pass = "bao0985265185" body = "User: pi\n" + "Password: raspberry\n" + "Your Ip connect to network: " + str(ipAdress) subject = "Information Camera System" message = MIMEMultipart() message['From'] = fromemail message['To'] = to message['Subject'] = subject message.attach(MIMEText(body, 'plain')) text = message.as_string() mail = smtplib.SMTP('smtp.gmail.com', 587) mail.ehlo() mail.starttls() mail.login(fromemail,your_pass) mail.sendmail(fromemail,to,text) mail.close() now = datetime.now() formatted_date = now.strftime('%Y-%m-%d %H:%M:%S') TRIG = 23 BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 88 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP ECHO = 24 space = 20 GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(TRIG,GPIO.OUT) GPIO.setup(ECHO,GPIO.IN) GPIO.setup(space,GPIO.OUT) continu = SampleNum=0 writer = None pulse_start = pulse_end = code = "" chophep = KEYPAD = [ ["1","2","3","A"], ["4","5","6","B"], ["7","8","9","C"], ["*","0","#","D"] ] ROW_PINS = [25, 8, 7, 1] COL_PINS = [17, 27, 22, 10] factory = rpi_gpio.KeypadFactory() keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS) # Open file json and read password def openjson(): with open ("/home/pi/Desktop/code-on-rasp/password.json","r") as read_file: data = json.load(read_file) getpass = data['password'] return getpass # handler when press key def printKey(key): print(key) global chophep password = openjson() if (key == 'D'): chophep = key = '' if (chophep == 1): global code code += key if (len(code) == 4): print(code) if (code == password): print("Open Door") GPIO.output(space,True) time.sleep(5) BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 89 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP GPIO.output(space,False) print("Close Door") code = "" chophep = else: print("Invalid") code = "" # Decleare information about ultra def ultra(TRIG,ECHO): global pulse_start global pulse_end GPIO.output(TRIG, False) time.sleep(2) GPIO.output(TRIG,True) time.sleep(0.00001) GPIO.output(TRIG,False) while GPIO.input(ECHO) == 0: pulse_start = time.time() while GPIO.input(ECHO) == 1: pulse_end = time.time() pulse_duration = pulse_end - pulse_start distance = pulse_duration * 17150 distance = round(distance,2) return distance # Decleare information about mysql and python def commitdata(name,formatted_date): try: connection = mysql.connector.connect(host = "103.95.197.126", user = "baopqspkt", passwd = "bao0985265185", database = "baopqspk_control") sql_insert_query = """ INSERT INTO `Door` (`Day`,`Name`) VALUES (%s,%s)""" cursor = connection.cursor() result = cursor.execute(sql_insert_query,(formatted_date,name)) connection.commit() #print ("Commit Done") except mysql.connector.Error as error : connection.rollback() #rollback if any exception occured #print ("Commit Error {}".format(error)) finally: #closing database connection if(connection.is_connected()): cursor.close() connection.close() # Declare Path def pathinfor(dev): fulldir = "/media/pi/"+dev return fulldir def deletefolder(fulldir,folder1,folder2): disk = os.statvfs(fulldir) totalAvailSpace = float(disk.f_bsize*disk.f_bfree) BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 90 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP if (totalAvailSpace < 500): GPIO.output(space,True) else : GPIO.output(space,False) if (totalAvailSpace < 100): shutil.rmtree(folder1) shutil.rmtree(folder2) # re-make folder after delete if not os.path.isdir(folder1): os.makedirs(folder1) if not os.path.isdir(folder2): os.makedirs(folder2) print("Delete Done") else: print ("Not Delete Because Have More Space") def movefile(pathimagelocal,pathimageusb,pathvideolocal,pathvideousb): shutil.move(pathimagelocal,pathimageusb) shutil.move(pathvideolocal,pathvideousb) def checkusb(pathimagelocal,pathvideolocal): Name = os.listdir("/media/pi/") if (len(Name) > 0): pathimageusb = pathinfor(str(Name[0])) + "/Image" if not os.path.isdir(pathimageusb): os.makedirs(pathimageusb) pathvideousb = pathinfor(str(Name[0])) + "/Video" if not os.path.isdir(pathvideousb): os.makedirs(pathvideousb) deletefolder(pathinfor(str(Name[0])),pathimageusb,pathvideousb) movefile(pathimagelocal,pathimageusb,pathvideolocal,pathvideousb) else : print("Don't Have USB") data = pickle.loads(open("/home/pi/Desktop/code-on-rasp/encoding.pickle", "rb").read()) detector = cv2.CascadeClassifier("/home/pi/Desktop/code-onrasp/haarcascade_frontalface_default.xml") vs = VideoStream(src=0).start() #vs = VideoStream(usePiCamera=True).start() time.sleep(2.0) now = datetime.now() date = now.day dateold = date+1 Name = os.listdir("/media/pi/") mypath = pathinfor(str(Name[0])) keypad.registerKeyPressHandler(printKey) # loop over frames from the video file stream while True: while date != dateold: GPIO.output(TRIG,False) BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 91 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP distance = ultra(TRIG,ECHO) print(distance) now = datetime.now() minute = now.minute hour = now.hour date = now.day month = now.month year = now.year frame = vs.read() frame = imutils.resize(frame, width = 600) if (distance > 50) and (distance < 100): gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) rects = detector.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=2, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE) boxes = [(y, x + w, y + h, x) for (x, y, w, h) in rects] encodings = face_recognition.face_encodings(rgb, boxes) names = [] for encoding in encodings: matches = face_recognition.compare_faces(data["encodings"], encoding) name = "Unknown" # check to see if we have found a match if True in matches: matchedIdxs = [i for (i, b) in enumerate(matches) if b] counts = {} for i in matchedIdxs: name = data["names"][i] counts[name] = counts.get(name, 0) + name = max(counts, key=counts.get) names.append(name) print(name) if (name == "Unknown"): print("Unknown") pathimagelocal = "/home/pi/Desktop/code-onrasp/Nguoila" pathimagelocalarg = pathimagelocal pathimagelocal= pathimagelocal + '/' + str(year) + '' + str(month) + '-' + str(date) + '/' if not os.path.isdir(pathimagelocal): os.makedirs(pathimagelocal) frame = vs.read() cv2.imwrite(pathimagelocal + str(hour) + '-' + str(minute) + '-' + '.jpg',frame) break else: commitdata(name,formatted_date) GPIO.output(space,True) time.sleep(5) GPIO.output(space,False) break pathvideolocal = "/home/pi/Desktop/code-on-rasp/output" pathvideolocalarg = pathvideolocal BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 92 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP pathvideolocal = pathvideolocal + '/' + str(date) + '-' + str(month) + '-' + str(year) if not os.path.isdir(pathvideolocal): os.makedirs(pathvideolocal) pathvideolocal = pathvideolocal + "/home.avi" if writer is None and pathvideolocal is not None: fourcc = cv2.VideoWriter_fourcc(*'XVID') writer = cv2.VideoWriter(pathvideolocal, fourcc, 5.0 , (frame.shape[1],frame.shape[0]), True) if writer is not None: writer.write(frame) cv2.imshow("Frame", frame) checkusb(pathimagelocalarg,pathvideolocalarg) dateold = date + cv2.destroyAllWindows() vs.stop() #Move file Video to USB #pathvideousb = "/media/pi/KINGSTON/Video/output" #Delete file before copy to usb #shutil.rmtree(pathvideousb) #shutil.move("/home/pi/Downloads/pi-facerecognition/output","/media/pi/KINGSTON/Video") #shutil.move("/home/pi/Downloads/pi-facerecognition/Nguoila","/media/pi/KINGSTON/Nguoila") #check to see if the video writer point needs to be release if writer is not None: writer.release() Chương trình mã hóa hình ảnh from tkinter import * from tkinter import messagebox from PIL import ImageTk, Image from imutils import paths import face_recognition import argparse import pickle import cv2 import os from pexpect import pxssh import socket import json root = Tk() root.title("Encode file") root.geometry("400x500") oldpassword = StringVar() newpassword = StringVar() AddressIP = StringVar() BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 93 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP userpi = StringVar() passwordpi = StringVar() t = Text(root, height=200, width=100) # def dataset_adress(): ## c = a.get() ## c = c.replace('\\','/') # return c # def encode_adress(): ## c = b.get() ## c = c.replace('\\','/') # return c def scp(hostname, username, password): s = pxssh.pxssh() try: s.login(hostname, username, password, sync_multiplier=5, auto_prompt_reset=False) s.sendline('pkill -f pi_face_recognition.py') s.prompt() print("Kill Done") os.system(" /Users/bpham/Desktop/GUI-master/encode/scp.command") print("Reboot") s.sendline('sudo reboot -h now') s.prompt() s.logout() messagebox.showinfo('Information', 'Done') except Exception as e: messagebox.showinfo("Error",str(e)) def scppassword(hostname, username, password): s = pxssh.pxssh() try: s.login(hostname, username, password, sync_multiplier=5, auto_prompt_reset=False) s.sendline('pkill -f pi_face_recognition.py') s.prompt() print("Kill Done") os.system(" /Users/bpham/Desktop/GUImaster/encode/changepass.command") print("Reboot") s.sendline('sudo reboot -h now') s.prompt() s.logout() messagebox.showinfo('Information', 'Complie complette') except Exception as e: messagebox.showinfo("Transfer error",str(e)) def ExitApplication(): MsgBox = messagebox.askquestion( 'Exit Application', 'Are you want to exit', icon='warning') if MsgBox == 'yes': root.destroy() else: BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 94 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP messagebox.showinfo( 'Return', 'You will now return to the application screen') def writeToJSONFile(path, fileName, data): filePathNameWExt = path + '/' + fileName + '.json' with open(filePathNameWExt, 'w') as fp: json.dump(data, fp) messagebox.showinfo('Information', 'Change Done') def changepassword(): chophep = hostname = AddressIP.get() username = userpi.get() password = passwordpi.get() try: socket.inet_aton(hostname) chophep = except socket.error: messagebox.showinfo('Information', 'Invalid IP Please Try Again') data = {} if (newpassword.get() == oldpassword.get()): messagebox.showinfo('Information', 'The Same Password') if (chophep == 1): data['password'] = newpassword.get() writeToJSONFile('/Users/bpham/Desktop/GUI-master/encode', 'password', data) scppassword(hostname, username, password) def clicked(): check = hostname = AddressIP.get() username = userpi.get() password = passwordpi.get() try: socket.inet_aton(hostname) check = except socket.error: messagebox.showinfo('Information', 'Invalid IP Please Try Again') if check == 1: imagePaths = list(paths.list_images( "/Users/bpham/Desktop/GUI-master/encode/dataset")) knownEncodings = [] knownNames = [] print("Start Encode") for (i, imagePath) in enumerate(imagePaths): print("[INFO] processing image {}/{}".format(i + 1, len(imagePaths))) name = imagePath.split(os.path.sep)[-2] BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 95 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha ĐỒ ÁN TỐT NGHIỆP image = cv2.imread(imagePath) rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) boxes = face_recognition.face_locations(rgb, model="hog") encodings = face_recognition.face_encodings(rgb, boxes) for encoding in encodings: knownEncodings.append(encoding) knownNames.append(name) data = {"encodings": knownEncodings, "names": knownNames} f = open("/Users/bpham/Desktop/GUImaster/encode/encoding.pickle", "wb") f.write(pickle.dumps(data)) f.close() print("Done Encode") scp(hostname, username, password) noidung = """ Encode file from image to file pickle Read email and Fill Out Let's start Author: baopq.spkt@gmail.com """ # Component Button(root, text='Quit', command=ExitApplication, fg="Red").pack(fill=X) Label(root, text='Old Password *', fg="Red").pack(fill=X) Entry(root, textvariable=oldpassword).pack(fill=X) Label(root, text='New Password (Only Number) *', fg="Red").pack(fill=X) Entry(root, textvariable=newpassword).pack(fill=X) Button(root, text='Change Password', command=changepassword, fg="green").pack(fill=X) Button(root, text='Encode File', command=clicked, fg="green").pack(fill=X) Label(root, text='Your IP (*)', fg="Red").pack(fill=X) text = Entry(textvariable=AddressIP).pack(fill=X) Label(root, text='User Name (*)', fg="Red").pack(fill=X) text = Entry(textvariable=userpi).pack(fill=X) Label(root, text='Password (*)', fg="Red").pack(fill=X) text = Entry(textvariable=passwordpi).pack(fill=X) t.pack(fill=X) t.insert(END, noidung) root.mainloop() BỘ MÔN ĐIỆN TỬ CÔNG NGHIỆP – Y SINH an (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha 96 (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha (Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha(Do.an.hcmute).nghien.cuu thiet.ke.va.thi.cong.cua.nhan.dang.khuon.mat.va.dieu.khien giam.sat.cac.thiet.bi.trong.nha

Ngày đăng: 01/01/2024, 19:46

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

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

Tài liệu liên quan