(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

129 3 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

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 LUẬN VĂN THẠC SĨ PHAN TIẾN VƯƠNG 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 NGÀNH: KỸ THUẬT CƠ KHÍ ĐỘNG LỰC – 60520116 S K C0 Tp Hồ Chí Minh, tháng 10/2015 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 LUẬN VĂN THẠC SĨ PHAN TIẾN VƢƠNG 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 NGÀNH: KỸ THUẬT CƠ KHÍ ĐỘNG LỰC – 60520116 Tp Hồ Chí Minh, tháng 10/2015 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 LUẬN VĂN THẠC SĨ PHAN TIẾN VƢƠNG 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 Hƣớng dẫn khoa học: TS LÊ THANH PHÚC Tp Hồ Chí Minh, tháng 10/2015 LÝ LỊCH KHOA HỌC I LÝ LỊCH SƠ LƢỢC: Họ & tên: PHAN TIẾN VƢƠNG Giới tính: Nam Ngày, tháng, năm sinh: 20/10/1989 Nơi sinh: Đồng Nai Quê quán: Quảng Trị Dân tộc: Kinh Địa liên lạc: 13/46 Kp 3, Đƣờng 11, P Linh Chiểu Thủ Đức TP.HCM Điện thoại quan: Điện thoại nhà riêng: Điện thoại di động: 01683675350 E-mail: pppvuong@gmail.com II QUÁ TRÌNH ĐÀO TẠO: Đại học: Hệ đào tạo: Chính qui Thời gian từ 09/2007 đến 07/2012 Nơi học: Trƣờng Đại học sƣ phạm kỹ thuật Thành phố Hồ Chí Minh Ngành học: Cơ khí động lực Tên đồ án, luận án môn thi tốt nghiệp: Chuyên đề 1, Chuyên đề 2, Chuyên đề Ngày & nơi bảo vệ đồ án, luận án thi tốt nghiệp: 23/07/2012 Ngƣời hƣớng dẫn: III Q TRÌNH CƠNG TÁC CHUN MƠN TỪ KHI TỐT NGHIỆP ĐẠI HỌC: Cơng việc đảm nhiệm Thời gian Nơi công tác 11/2013– 08/2014 Trƣờng Trung Cấp Kinh Tế - Kỹ Giáo viên khoa Cơ Khí Thuật Nguyễn Hữu Cảnh 08/2014 - Trƣờng Cao Đẳng Giao Thông Giảng viên khoa Kỹ Vận Tải Thành Phố Hồ Chí Thuật Ơ Tơ Minh i 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 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 ln 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 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 ngồi 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 - 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 Hồ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 Tồ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, Hoà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 ... DỤC VÀ ĐÀO TẠO TRƢỜNG ĐẠI HỌC SƢ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ PHAN TIẾN VƢƠNG 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... đề 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... thấp, công nghiệp ô tô chƣa phát triển mạnh so với giới Do 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

Ngày đăng: 06/12/2021, 21:32

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

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

Tài liệu liên quan