(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động

133 2 0
(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động

Đ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

(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động(Luận văn thạc sĩ) Nghiên cứu thuật toán nhận dạng người đi đường, xe và chướng ngại vật cho ô tô chạy tự động

LỜI CAM ĐOAN Tơi cam đoan cơng trình nghiên cứu Các số liệu, kết nêu luận văn trung thực chƣa đƣợc cơng bố cơng trình khác TP.HCM, ngày 23 tháng 10 năm 2015 (Ký tên ghi rõ họ tên) Phan Tiến Vƣơng ii LỜI CẢM ƠN Một đề tài nghiên cứu thành công khơng có trợ giúp kết hợp với nỗ lực cố gắng ngƣời nghiên cứu Do đó, tơi xin chân thành cảm ơn hỗ trợ của: Ban giám hiệu Trƣờng Đại Học Sƣ Phạm Kỹ Thuật TP HCM Khoa Cơ Khí Động Lực Thầy TS Lê Thanh Phúc tồn thể q thầy dạy hƣớng dẫn nhiệt tình tạo điều kiện thuận lợi cho thời gian theo học trƣờng Các bạn kỹ sƣ đồng nghiệp động viên ủng hộ tinh thần Tuy thời gian thực đề tài tháng nhƣng lƣợng kiến thức chủ chốt để phục vụ cho công tác nghiên cứu thực đề tài thuộc chuyên ngành điện tử điều khiển tự động, công nghệ thông tin nên khả tiếp cận lĩnh hội học viên chuyên ngành khí động lực gặp nhiều khó khăn hạn chế Tuy nhiên, với hƣớng dẫn tạo điều kiện thuận lợi Thầy TS Lê Thanh Phúc bạn đồng nghiệp, lĩnh hội đƣợc nhiều kiến thức mới, bổ ích để phục vụ cho ngành khí động lực cơng tác nghiên cứu sau trƣờng Vì vậy, lần tơi xin chân thành cảm ơn quý thầy cô bạn Xin chúc q thầy tồn thể bạn dồi sức khoẻ thành công! TP.HCM, ngày 23 tháng 10 năm 2015 Ngƣời cảm ơn Phan Tiến Vƣơng iii TÓM TẮT Nhận dạng ngƣời đƣờng, xe chƣớng ngại vật đề tài hỗ trợ cảnh báo cho ngƣời lái xe cho hệ thống giao thơng thơng minh Mơ hình nhận ngƣời đƣờng với giả định tỉ lệ kích thƣớc ngƣời ảnh không đổi Nhận dạng ngƣời đƣờng dùng giải thuật máy học SVM với đặc trƣng HOG Mơ hình nhận xe với tỉ lệ kích thƣớc xe ảnh thay đổi Nhận dạng xe chƣớng ngại vật dùng Cascade of boosting với đặc trƣng HOG Thực nghiệm cho thấy kết nhận dạng tốt: Nhận dạng ngƣời đƣờng đạt độ xác 91% dùng 4,500 ảnh dƣơng (ảnh ngƣời đƣờng), 4,000 ảnh âm (không phải ngƣời đƣờng) 200 ảnh để kiểm tra Nhận dạng xe đạt độ xác 93% dùng 1500 ảnh dƣơng (ảnh xe), 3,000 ảnh âm (không phải xe) 200 ảnh để kiểm tra Nhận dạng chƣớng ngại vật đạt độ xác 84% dùng 100 ảnh dƣơng (chƣớng ngại vật), 1,000 ảnh âm (không phải chƣớng ngại vật) 50 ảnh để kiểm tra Đề tài nghiên cứu sử dụng Webcam làm phận thu hình ảnh đƣợc gắn xe tơ xử lý phần mềm Matlab chạy thực nghiệm đƣờng cho kết nhận dạng tốt Đề tài xây dựng đƣợc chƣơng trình nhận dạng ngƣời đƣờng, xe chƣớng ngại vật iv ABSTRACT Pedestrians detection, vehicle detection and object recognition are applied to support drivers in warning them and to intelligent transportation system The system which detects pedestrians is based on an assumption that the sizes of human images are fixed Human dectection process employs Support Vector Machine- Histograms of Oriented Gradients And the system identifies vehicles when the sizes of those in the images are changeable Vehicle detection and object recognition process employs Cascade of boosting -Histograms of Oriented Gradients Experiments show fairly good results: pedestrians acquisition process gained a 91% accuracy after analysing 3500 positive images (images of pedestrians), 4000 negative images (non-pedestrians) and 200 testing images Vehicles acquistition process gained a 93.1 % accuracy after analysing 1500 positive images (images of vehicles), 2000 negative images (non-vehicle) and 200 testing images Obstacles acquisition process gained a 84 % accuracy after analysing 100 positive images (images of obstacles), 1000 negative images (non-obstacle) and 50 testing images This research uses webcam built in cars as the major camera and works with Matlab Practical experiments on the streets have achieved good acquisition results.The research also creates a programme identifying pedestrians, vehicles and obstacles v MỤC LỤC Trang tựa TRANG Quyết định giao đề tài Lý lịch khoa học i Lời cam đoan ii Lời cảm ơn iii Tóm tắt iv Mục lục vi Danh sách chữ viết tắt xi Danh sách hình xii Danh sách bảng xvi CHƢƠNG TỔNG QUAN 1.1 Tổng quan chung lĩnh vực nghiên cứu 1.1.1 Giới thiệu 1.1.2 Nhận dạng ngƣời đƣờng 1.1.3 Hệ thống cảnh báo sớm phát ngƣời đƣờng xe 1.1.4 Nhận dạng xe chƣớng ngại vật 1.1.5 Mơ hình nhận dạng xe tổng quát 1.1.6 Hệ thống cảnh báo va chạm (Forward Collision Warning) 1.1.7 Phƣơng pháp nhận dạng ngƣời đƣờng xe chƣớng ngại vật xử lý ảnh 1.2 Các kết nghiên cứu nƣớc công bố 1.2.1 Các kết nghiên cứu nƣớc 1.2.2 Các kết nghiên cứu quốc tế 1.3 Mục đích đề tài 10 1.4 Phƣơng pháp nghiên cứu 10 1.5 Ý nghĩa khoa học tính thực tiễn đề tài 11 1.6 Giới hạn đề tài 11 1.7 Kế hoạch thực 11 vi CHƢƠNG CƠ SỞ LÝ THUYẾT 12 2.1 Lý thuyết tổng quan xử lý ảnh 12 2.1.1 Ảnh số gì? 14 2.1.2 Hệ thống xử lý ảnh 15 2.2 Các vấn đề xử lý ảnh 15 2.2.1 Biểu diễn mơ hình hóa ảnh 15 2.2.2 Tăng cƣờng ảnh 17 2.2.3 Nắn chỉnh biến dạng 17 2.2.4 Khử nhiễu 18 2.2.5 Chỉnh mức xám 18 2.2.6 Trích chọn đặc điểm 18 2.2.7 Đặc điểm biên đƣờng biên 19 2.2.8 Nhận dạng 19 2.2.9 Nén ảnh 20 2.2.10 Đo khoảng cách pixels 21 2.3 Các mơ hình màu 22 2.3.1 Mơ hình màu RGB 23 2.3.2 Mơ hình màu CMY 24 2.3.3 Mơ hình HSV 24 2.3.4 Mơ hình sáng 25 2.4 Đặc Trƣng Haar-like 25 2.5 Thuật toán AdaBoost 29 2.6 Bộ phân lớp Cascade 32 2.7 Bộ phân lớp Cascade of boosting 34 2.8 Đặc trƣng Histogram of Oriented Gradients 35 2.8.1 Nhập ảnh 36 2.8.2 Chuẩn hóa Gamma & Colour 36 2.8.3 Tính Gradient 37 2.8.4 Chia hƣớng & gom đặc trƣng nhóm cell 39 vii 2.8.5 Tính đặc trƣng cho khối chuẩn hóa 41 2.8.6 Tính vector đặc trƣng cho cửa sổ 42 2.9 Máy vector hỗ trợ (SVM) 43 2.9.1 Siêu phẳng - Hyperplane 43 2.9.2 SVM tuyến tính 43 2.9.3 Các điều kiện Karush-Kuhn-Tucker (KKT) 45 2.9.4 Giải thuật SMO 45 CHƢƠNG THUẬT TOÁN NHẬN DẠNG 48 3.1 Giới thiệu MATLAB 48 3.1.1 Khởi động Matlab 48 3.1.2 Một số lệnh thông dụng Matlab 49 3.1.3 Lập trình MATLAB 50 3.1.4 Matlab GUIDE 50 3.2 Nhận dạng ngƣời đƣờng sử dụng HOG SVM 52 3.2.1 Tạo liệu mẫu huấn luyện âm mẫu huấn luyện dƣơng 52 3.2.2 Huấn luyện SVM 56 3.2.3 Nhận dạng ngƣời đƣờng 58 3.3 Nhận dạng xe chƣớng ngại vật 64 3.3.1 Tạo huấn luyện nhận dạng mẫu nhận dạng xe chƣớng ngại vật 64 3.3.2 Hoạt động xử lý phân loại 65 3.3.3 Tạo nhãn nhận dạng cho mẫu 66 3.3.4 Sử dụng TrainCascadeObjectDetector tạo mẫu 70 3.3.5 Nhận dạng đối tƣợng từ mẫu huấn luyện 73 3.4 Đo khoảng cách từ camera tới đối tƣợng 77 3.4.1 Mơ hình đo khoảng cách ảnh 77 3.4.2 Kỹ Thuật camera calibration 79 CHƢƠNG THỰC NGHIỆM VÀ ĐÁNH GIÁ 83 4.1 Thực nghiệm 83 4.1.1 Thông số Webcam 83 viii 4.1.2 Kết thực nghiện 88 4.2 Đánh giá 101 4.2.1 Độ xác 101 4.2.2 Tốc độ thu thập 103 CHƢƠNG KẾT LUẬN VÀ ĐỀ NGHỊ 104 5.1 Kết đạt đƣợc 104 5.2 Những vấn đề tồn 104 5.3 Hƣớng phát triển 105 TÀI LIỆU THAM KHẢO 106 PHỤ LỤC 109 ix DANH SÁCH CÁC CHỮ VIẾT TẮT MATLAB Maxtrix Laboratory CMU Carnegie Mellon University MIT Massachusetts Institute of Technology DARPA Defense Advanced Research Projects Agency HDTV High-definition television ROI Regions of Interest RGB Red, Green, Blue HSL Hue, Saturation, Luminance 2D Two Demension 3D Three Demension TIFF Targed Image File Format JPEG Joint Photographics Experts Group GIF Graphics Interchange Format BMP Window Bitmap PNG Portable Network Graphics XWD X Window Dump PCX Personal Computer Exchange CMY HOG SIFT PCA CBC SVM DAB AdaBoost RAB DAB GAB Cyan, Magnenta, Yellow Histograms of Oriented Gradients Scale-Invariant Feature Transform Principal component analysis Cascade of boosting Classifier Support Vector Machine Discrete AdaBoost Real AdaBoost Gentle AdaBoost True Positive False Positive True Negative False Negative TP FP TN FN x DANH SÁCH CÁC HÌNH HÌNH TRANG Hình 1.1: Ứng dụng sản phẩm TMPV760 [1] Hình 1.2: Nhận dạng ngƣời đƣờng [2] Hình 1.3: Phát ngƣời đƣờng cơng nghệ khơng dây [3] Hình 1.4: Mơ hình tổng qt giải tốn nhận dạng xe [6] Hình 1.5: Cảnh báo va chạm sử dụng camera cảm biến [6] Hình 1.6: Nhận dạng xe phƣơng pháp khác [6] Hình 2.1: Ảnh tƣơng tự ảnh số [17] 14 Hình 2.2: Hệ thống xử lý ảnh [17] 15 Hình 2.3: a, ảnh thật, b, ảnh zoom, c, ma trận điểm [17] 16 Hình 2.4: Ảnh thu nhận ảnh mong muốn [17] 17 Hình 2.5: Mơ hình màu [17] 23 Hình 2.6: Hệ tọa độ màu RGB [17] 24 Hình 2.7: Mơ hình màu HSV [17] 25 Hình 2.8: Đặc trƣng Harr-like [18] 26 Hình 2.9: Các đặc trƣng mở rộng đặc trƣng Haar-like sở [18] 26 Hình 2.10: Cách tính Integral Image ảnh [18] 27 Hình 2.11: Ví dụ cách tính nhanh tổng điểm ảnh vùng D ảnh 27 Hình 2.12: Cách tính nhanh tổng điểm ảnh vùng D ảnh với đặc trƣng xoay 45o [18] 28 Hình 2.13: Ví dụ cách tính nhanh tổng điểm ảnh vùng D ảnh [18] 28 Hình 2.14: Lƣợc đồ AdaBoot [18] 29 Hình 2.15: Thuật tốn học AdaBoot [18] 30 Hình 2.16: Bộ phân loại cascade of classifiers [19] 34 Hình 2.17: Bộ phân lớp cascade of boosted classifiers [19] 34 Hình 2.18: Sơ đồ rút trích đặc trƣng HOG [20] 36 Hình 2.19: Hình ảnh miêu tả Sơ đồ rút trích đặc trƣng HOG [20] 37 xi - Với khoảng cách xa xe chạy tốc độ cao yêu cầu camera tốc độ cao để xử lý 5.3 Hƣớng phát triển Đề tài chƣa áp dụng cho xe tham gia giao thơng thực tế Vì để áp dụng đƣợc vào thực tế giao thơng cần áp dụng thực tiếp số nội dung sau đây: - Nghiên cứu thuật toán xử lý ảnh nhận dạng ngƣời đƣờng, xe chƣớng ngại vật vào ban đêm - Nghiên cứu thuật toán xác định khoảng cách ngƣời đƣờng, xe chƣớng ngại vật sử dụng hai camera - Nghiên cứu chế tạo thiết bị cảnh báo sớm va chạm ngƣời, xe chƣớng ngại vật - Nghiên cứu thuật toán kết hợp xử lý ảnh, điều khiển tự động với hệ thống lái để tránh đƣợc vật cản đƣờng 105 TÀI LIỆU THAM KHẢO [1] Toshiba Launches New Line-up of Image Recognition Processors for Automotive Applications Internet: http://toshiba.semicon-storage.com, 20/03/2013 [2] Pedestrian Detection by Mobileye Internet: https://www.flickr.com/photos/mobileyeproducts/4614100229 , 22/03/2013 [3] Driver demand for connected cars grows Internet: http://electronicsmaker.com/driver-demand-for-connected-cars-grows, 28/03/2013 [4] Automotive night vision Internet: https://en.wikipedia.org/wiki/Automotive_night_vision, [5] Mona Saini, Survey on Vision Based On-Road Vehicle Detection, International Journal of u-and e-Service, Science and Technology, Vol 14 , Issue 4, pp 1773 – 1795, 2014 [6] Mohan M.Trivedi, Chair Serge Belongie,Sanjoy Dasgupta,Kenneth KreutzDelgado, Bhaskar Rao, Learning Modeling and Understanding Vehicle Surround UsingMulti-Modal Sensing, University of California San Diego, 2013 [7] Nguyễn Xuân Tƣờng Huy, Nguyễn Hoàng Vũ, Tìm hiểu kỹ thu t phát người video giám sát lớp học, LVĐH, Trƣờng Đại Học Khoa Học Tự Nhiên, 2010 [8] Vũ Hồng Phong, Nh n Dạng Xe Trên Cơ Sở Thị Giác Máy Tính, LVThs, đại học Bách Khoa Thành Phố Hồ Chí Minh, năm 2008 [9] Văn Ánh Dƣơng, Nghiên Cứu Thu Th p Và Xử Lý Ảnh Để Hỗ Tr Ơ Tơ Chạy Tự Động, LVThs, Trƣờng Đại Học Sƣ Phạm Kỹ Thuật Tp.HCM, 2015 [10] Navneet Dalal and Bill Triggs, Histograms of Oriented Gradients for Pedesttrian Detection, Computer Vision and Pattern Recognition, vol.1, pp.886 - 893, 2005 106 [11] Prisacariu VA, Reid ID, Fast HOG-A real-time GPU implementation of HOG Technical Report, 2009 [12] Jon Arróspide, Luis Salgado and Javier Marinas, HOG-like Gradient-based Descriptor for Visual Vehicle Detection, Intelligent Vehicles Symposium, vol 4, pp 223 – 228, June 2012 [13] Yinghong Li, Zhengxi Li, Hongfang Tian, Yuquan Wang, Vehicle Detecting and Shadow Removing Based on Edged Mixture Gaussian Model, IEEE Transactions on, pp 998 – 1007, 2011 [14] Zehang Sun, Bebis G and Miller R, On-road Vehicle Detection Using Evolutionary Gabor Filter Optimization, Intelligent Transportation Systems, Vol , Issue 2, pp 125 – 137, June 2005 [15] David G.Lowe, Distinctive Image Features from Scale-Invariant Keypoints, International Journal of Computer Vision, Vol 60, Issue , pp 91-110, 2004 [16] JAE.LIM, Nguyễn Văn Ngọ, Giáo trình xử lý ảnh, Đại học Quốc Gia Hà Nội, 2001, tr 31-40 [17] Đỗ Năng Toàn, Phạm Việt Bình, Giáo trình xử lý ảnh, Đại học Thái Nguyên, 2007, tr 41 [18] Julien Meynet Fast Face Detection Using AdaBoost EPFL-STUDENT, 16th July 2003, pp 10-31 [19] Berkin Bilgic, Berthold K.P Horn, and Ichiro Masaki, Fast Human Detection With Cascaded Ensembles On The GPU, IEEE Intelligent Vehicles Symposium University of California, vol.4, pp 325 – 332, June 2010 [20] Navneet DALAL, Finding People in Images and Videos, Institut National Polytechnique de Grenoble, Institut National Polytechnique De Grenoble, pp 14, 2006 [21] Võ Đức Khánh, Hồng Kiếm, Giáo trình xử lý ảnh, Đại học Quốc Gia Tp Hồ Chí Minh, 2008, tr 56 [22] Nguyễn Thanh Hải, Xử lý ảnh, Đại học Quốc Gia Tp Hồ Chí Minh, 2014,tr 159-163 107 [23] Phan Thanh Tạo, Giáo trình Matlab, Đại học Bách Khoa Đà Nẵng, 2004, tr 14 [24] vision.CascadeObjectDetector System object Internet: http://www.mathworks.com/help/vision/ref/vision.cascadeobjectdetectorclass.html?refresh=true, 06/08/2014 [25] Chu Jiangwei, Ji Lisheng Guo, Lie Libibing, Wang Rongben, Study on Method of Detecting Preceding Vehicle Based on Monocular Camera, IEEE Intelligent Vehicles Symposium University of Parma Pama, pp.750-755, 2004 [26] Boguslaw Cyganek, Object Detection and Recognition in Digital Images Theory and Practice, AGH University of Science and Technology, Poland, pp 215, 2013 [27] Chin-Teng Lin, Sheng-Chih Hsu, Ja-Fan Lee, Chien-Ting Yang, Boosted Vehicle Detection Using Local and Global Features, Journal of Signal and Information Processing, vol.4, pp 243-252, 2013 [28] M.Bertozzi and A.Broggi, GOLD: A parallel real-time stereo vision system for generic obstacle and lane detection, IEEE Transaction on Image Processing, pp.199-213, 1998 [29] ZuWhan Kim, Realtime Lane Tracking of Curved Local Road, in IEEE Intelligent Transporation Systems, pp.1149-1155, 2006 [30] Y Wang, E.K.Teoh, and D.Shen, Lane detection and tracking using BSnake, Image and Vision Computing, vol 22, pp 269-280, 2004 108 PHỤ LỤC Chƣơng trình Guide nhận dạng function varargout = luanvannhandang(varargin) % LUANVANNHANDANG MATLAB code for luanvannhandang.fig % LUANVANNHANDANG, by itself, creates a new LUANVANNHANDANG or raises the existing % singleton* % H = LUANVANNHANDANG returns the handle to a new LUANVANNHANDANG or the handle to % the existing singleton* % LUANVANNHANDANG('CALLBACK',hObject,eventData,handles, ) calls the local % function named CALLBACK in LUANVANNHANDANG.M with the given input arguments % LUANVANNHANDANG('Property','Value', ) creates a new LUANVANNHANDANG or raises the % existing singleton* Starting from the left, property value pairs are % applied to the GUI before luanvannhandang_OpeningFcn gets called An % unrecognized property name or invalid value makes property application % stop All inputs are passed to luanvannhandang_OpeningFcn via varargin % *See GUI Options on GUIDE's Tools menu Choose "GUI allows only one % instance to run (singleton)" % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help luanvannhandang % Last Modified by GUIDE v2.5 22-Sep-2015 13:20:26 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; 109 gui_State = struct('gui_Name', mfilename, 'gui_Singleton', gui_Singleton, 'gui_OpeningFcn', @luanvannhandang_OpeningFcn, 'gui_OutputFcn', @luanvannhandang_OutputFcn, 'gui_LayoutFcn', [] , 'gui_Callback', []); if nargin && ischar(varargin{1}) 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 luanvannhandang is made visible function luanvannhandang_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to luanvannhandang (see VARARGIN) % Choose default command line output for luanvannhandang % Choose default command line output for luanvan handles.output = hObject; load ('nguoididuong.mat’); detector = vision.CascadeObjectDetector('xe20x20.xml'); detector 1= vision.CascadeObjectDetector('xe64x64.xml'); detector 2= vision.CascadeObjectDetector('xe128x128.xml'); 110 detector 3= vision.CascadeObjectDetector('chuonggaivat.xml'); handles.video = videoinput('winvideo', 1, 'MJPG_640x480'); vidRes = get(handles.video, 'VideoResolution'); nBands = get(handles.video, 'NumberOfBands'); hImage = image( zeros(vidRes(2), vidRes(1), nBands),'Parent',handles.webcam); preview(handles.video,hImage); set(handles.video,'TimerPeriod', 0.05, 'TimerFcn',['if(~isempty(gco)),' 'handles=guidata(gcf);' % Update handles 'frame=getsnapshot(handles.video);,' 'imshow(rgb2gray(frame));,' 'set(handles.webcam,''ytick'',[],''xtick'',[]),' 'set(handles.hinhchup,''ytick'',[],''xtick'',[]),' % Remove tickmarks and labels that are inserted when using IMAGE 'else ' 'delete(imaqfind);' % Clean up - delete any image acquisition objects 'end']); triggerconfig(handles.video,'manual'); % Update handles structure guidata(hObject, handles); % UIWAIT makes luanvannhandang wait for user response (see UIRESUME) % uiwait(handles.figure1) % - Outputs from this function are returned to the command line function varargout = luanvannhandang_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB 111 % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % - Executes during object creation, after setting all properties % Hint: place code in OpeningFcn to populate axes1 % - Executes on button press in NDxe function NDxe_Callback(hObject, eventdata, handles) % hObject handle to NDxe (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Camera is on Stop camera and change button string frame=getsnapshot(handles.video); imwrite( frame, 'nhandangxe.png'); detector.MaxSize = [20 20]; detector1.MinSize = [20 20]; detector1.MaxSize = [64 64]; detector2.MaxSize = [128 128]; detector2.MinSize = [64 64]; I= imread('nhandangxe.png'); bboxes = step(detector,I); [n m]=size(bboxes); label_str = cell(n,1); b=[ ]; if n>=1 for i=1:n b(i,1)=abs(1.16/tan(atan((bboxes(i,4)+bboxes(i,2)-5-237.6)/635.1))); end 112 for i=1:n distanceAsString= sprintf('%0.2f meters', b(i,1)); label_str{i} = ['Xe ' distanceAsString ]; I=insertObjectAnnotation(I,'rectangle',bboxes(i,:), label_str{i},'Color', 'red','TextBoxOpacity',0.3,'FontSize',20); end end bboxes = step(detector1,I); [n m]=size(bboxes); label_str = cell(n,1); b=[ ]; if n>=1 for i=1:n b(i,1)=abs(1.16/tan(atan((bboxes(i,4)+bboxes(i,2)-5-237.6)/635.1))); end for i=1:n distanceAsString= sprintf('%0.2f meters', b(i,1)); label_str{i} = ['Xe ' distanceAsString ]; I=insertObjectAnnotation(I,'rectangle',bboxes(i,:), label_str{i},'Color', 'red','TextBoxOpacity',0.3,'FontSize',20); end end bboxes = step(detector2,I); [n m]=size(bboxes); label_str = cell(n,1); b=[ ]; if n>=1 113 for i=1:n b(i,1)=abs(1.16/tan(atan((bboxes(i,4)+bboxes(i,2)-5-237.6)/635.1))); end for i=1:n distanceAsString= sprintf('%0.2f meters', b(i,1)); label_str{i} = ['Xe ' distanceAsString ]; I=insertObjectAnnotation(I,'rectangle',bboxes(i,:), label_str{i},'Color', 'red','TextBoxOpacity',0.3,'FontSize',20); end end hImage = image(I,'Parent',handles.hinhchup ); % - Executes on button press in NDNGUOI function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (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 edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double % - Executes during object creation, after setting all properties function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (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'); 114 end function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (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 edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double % - Executes during object creation, after setting all properties function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (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 button press in NDNGUOI function NDNGUOI_Callback(hObject, eventdata, handles) % hObject handle to NDNGUOI (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) frame=getsnapshot(handles.video); imwrite( frame, 'nhandangnguoi.png’); I = imread('nhandangnguoi.png'); [bboxes,scores,hog] = vung_nhan_dang (I, w, hogCellSize, scales) 115 scores(any([-1 ; -1 1] * boxes < 0)) = -inf ; keep = false(1, size(boxes,2)) ; while true [score, best] = max(scores) ; if score == -inf, break ; end keep(best) = true ; remove = boxinclusion(boxes(:,best), boxes, 'pascalFormat', true) >= 0.2 ; scores(remove) = -inf ; scores(best) = -inf ; ROI=bboxes'; [n m]=size(ROI) for j= 1:m ROI(j,4)=ROI(j,4)-ROI(j,2) ; ROI(j,3)=ROI(j,3)-ROI(j,1) ; End [n m]=size(ROI); label_str = cell(n,1); b=[]; if n>=1 for i=1:n b(i,1)=1.164/tan(atan((bboxes(i,4)+bboxes(i,2) -237.6)/635.1)); end for i=1:n distanceAsString= sprintf('%0.2f meters', b(i,1)); label_str{i} = ['nguoi di duong ' distanceAsString ]; I=insertObjectAnnotation(I,'rectangle',ROI(i,:),label_str{i},'Color', 'red','TextBoxOpacity',0.3,'FontSize',20); end end 116 hImage = image(I,'Parent',handles.hinhchup ); % - Executes on button press in CHUNGNGAIVAT function CHUNGNGAIVAT_Callback(hObject, eventdata, handles) % hObject handle to CHUNGNGAIVAT (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) frame=getsnapshot(handles.video); imwrite( frame, 'chuongngaivat.png'); I= imread('chuongngaivat.png'); bbox = step(detector3,I); I = insertObjectAnnotation(I,'rectangle',bbox,'CHUONG NGAI VAT','TextBoxOpacity',0.9,'FontSize',20); hImage = image(I ,'Parent',handles.hinhchup ); % - Executes on button press in TONGHOP function TONGHOP_Callback(hObject, eventdata, handles) % hObject handle to TONGHOP (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) frame=getsnapshot(handles.video); imwrite( frame, 'mau1.png'); I= imread('mau1.png'); bboxes = step(detector,I); I=insertObjectAnnotation(I,'rectangle',bboxes,'Color', 'red','TextBoxOpacity',0.3,'FontSize',20); imwrite( I, 'mau2.png'); I = imread('mau2.png'); [bboxes,scores,hog] = vung_nhan_dang (I, w, hogCellSize, scales) scores(any([-1 ; -1 1] * boxes < 0)) = -inf ; keep = false(1, size(boxes,2)) ; 117 while true [score, best] = max(scores) ; if score == -inf, break ; end keep(best) = true ; remove = boxinclusion(boxes(:,best), boxes, 'pascalFormat', true) >= 0.2 ; scores(remove) = -inf ; scores(best) = -inf ; ROI=bboxes'; [n m]=size(ROI) for j= 1:m ROI(j,4)=ROI(j,4)-ROI(j,2) ; ROI(j,3)=ROI(j,3)-ROI(j,1) ; End I = insertObjectAnnotation(I,'rectangle',ROI,'NGUOI DI DUONG','Color', 'red','TextBoxOpacity',0.9,'FontSize',20); imwrite( I, 'mau3.png'); detector = vision.CascadeObjectDetector('chuonggaivat.xml'); I= imread('mau3.png'); bbox = step(detector3,I); I= insertObjectAnnotation(B,'rectangle',bbox,'CHUONG NGAI VAT','TextBoxOpacity',0.9,'FontSize',20); hImage = image(I,'Parent',handles.hinhchup ); % - Executes during object creation, after setting all properties function axes1_CreateFcn(hObject, eventdata, handles) % handles empty - handles not created until after all CreateFcns called h=imread('C:\Program Files\MATLAB\R2013a\toolbox\vision\visiondata\LUAN VAN\nen.jpg'); imshow(h) 118 S K L 0 ... thời đi? ??m chƣa có cơng trình nghiên cứu nhận dạng ngƣời đƣờng, xe chƣớng ngại vật cho ô tô chạy tự động 1.2.2 Các kết nghiên cứu quốc tế Trên giới có nhiều nghiên cứu nhận dạng ngƣời đƣờng, xe. .. đề tài Đề tài “NGHIÊN CỨU THUẬT TOÁN NHẬN DẠNG NGƢỜI ĐI ĐƢỜNG, XE VÀ CHƢỚNG NGẠI VẬT CHO Ô TÔ CHẠY TỰ ĐỘNG” giúp cho ngƣời tài xế đƣợc thoải mái xe chạy đƣờng cao tốc, đƣờng ? ?ô thi Đo khoảng... hành vi đối tƣợng để đi? ??u khiển ô tô chạy tự động 1.4 Phƣơng pháp nghiên cứu Để thực việc ứng dụng xử lý ảnh để nhận diện ngƣời đƣờng, xe chƣớng ngại vật cho ô tô chạy tự động, hƣớng tiếp cận

Ngày đăng: 23/12/2022, 15:24

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

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

Tài liệu liên quan