(Luận văn thạc sĩ hcmute) ứng dụng kỹ thuật phát hiện người trong giám sát an ninh

100 5 0
(Luận văn thạc sĩ hcmute) ứng dụng kỹ thuật phát hiện người trong giám sát an ninh

Đ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Ĩ NGUYỄN THỊ PHONG ỨNG DỤNG KỸ THUẬT PHÁT HIỆN NGƯỜI TRONG GIÁM SÁT AN NINH NGÀNH: KỸ THUẬT ĐIỆN TỬ SKC007447 Tp Hồ Chí Minh, tháng 10/2017 Luan van BỘGIÁO GIÁODỤC DỤCVÀ VÀĐÀO ĐÀOTẠO TẠO BỘ TRƢỜNGĐẠI ĐẠIHỌC HỌCSƢ SƢPHẠM PHẠMKỸ KỸTHUẬT THUẬT TRƢỜNG THÀNHPHỐ PHỐHỒ HỒCHÍ CHÍMINH MINH THÀNH CHUYÊN ĐỀ LUẬN VĂN LUẬN VĂN THẠC SĨ THẠC SĨ NGUYỄN THỊNGUYỄN PHONG THỊ PHONG HỌ VÀ TÊN HỌC VIÊN: NGHIÊN CỨU KỸ DỤNG ỨNG DỤNG KỸTHUẬT THUẬTNHẬN PHÁTDẠNG HIỆN ÁP NGƢỜI TRONG HỆ THỐNG SÁT AN NINH TRONG GIÁMGIÁM SÁT AN NINH NGÀNH: KỸ THUẬT ĐIỆN TỬ - 60520203 NGÀNH: KỸ THUẬT ĐIỆN TỬ Tp Hồ Chí Minh, tháng 10/2017 Luan van BỘ GIÁO GIÁO DỤC DỤC VÀ VÀ ĐÀO ĐÀO TẠO TẠO BỘ TRƢỜNG ĐẠI ĐẠI HỌC HỌC SƢ SƢ PHẠM PHẠM KỸ KỸ THUẬT THUẬT TRƢỜNG THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ NGUYỄN THỊ PHONG ỨNG DỤNG KỸ THUẬT PHÁT HIỆN NGƢỜI TRONG GIÁM SÁT AN NINH NGÀNH: KỸ THUẬT ĐIỆN TỬ - 60520203 Hƣớng dẫn khoa học: TS HOÀNG VĂN DŨNG CHUYÊN ĐỀ LUẬN VĂN THẠC SĨ HỌ VÀ TÊN HỌC VIÊN: NGUYỄN THỊ PHONG Tp Hồ Chí Minh, tháng 10/2017 Luan van Luan van Luan van LÝ LỊCH KHOA HỌC I LÝ LỊCH SƠ LƢỢC: Họ & tên: Nguyễn Thị Phong Giới tính: Nữ Ngày, tháng, năm sinh: 16/04/1974 Nơi sinh: Quảng Ngãi Quê quán: Quảng Ngãi Dân tộc: Kinh Chỗ riêng địa liên lạc: 5/3F đƣờng 297 – Khu phố – Phƣờng Phƣớc Long B – Quận – Tp.Hồ Chí Minh Điện Thoại: 0938123649 E-mail: cntdphong@gmail.com II QUÁ TRÌNH ĐÀO TẠO: Đại học: Hệ đào tạo: quy Thời gian đào tạo từ 1994 đến 1999 Nơi học (trƣờng, thành phố): Đại học sƣ phạm kỹ thuật Tp.HCM Ngành học: Kỹ thuật điện – điện tử Tên đồ án, luận án môn thi tốt nghiệp: Truyền thông tin mật mã RSA Ngày & nơi bảo vệ đồ án, luận án thi tốt nghiệp: 2/1999 trƣờng Đại học sƣ phạm kỹ thuật Tp.HCM Ngƣời hƣớng dẫn: Th.S Trần Vĩnh An Thạc sĩ: a.Hệ đào tạo: Chính qui Thời gian đào tạo từ /2004 đến / 2006 Nơi học (trƣờng, thành phố): Trƣờng Đại học Sƣ Phạm Kỹ Thuật TPHCM Ngành học: Giáo dục học Tên luận văn: Tổ ch c dạy học theo định hƣớng lực thực cho môn học Kỹ thuật số trƣờng Trung học Kỹ thuật Nghiệp vụ Th đ c Ngày & nơi bảo vệ luận văn: 22/10/2006 Ngƣời hƣớng dẫn: TS.V Thị Xuân i Luan van b.Hệ đào tạo: Chính qui Thời gian đào tạo từ /2016 đến 10/2017 Nơi học (trƣờng, thành phố): Trƣờng Đại học Sƣ Phạm Kỹ Thuật TPHCM Ngành học: Kỹ thuật điện tử Tên luận văn: ng dụng kỹ thuật phát ngƣời giám sát an ninh Ngày & nơi bảo vệ luận văn: 22/10/2017 Ngƣời hƣớng dẫn: TS Hoàng Văn D ng III QUÁ TRÌNH CƠNG TÁC CHUN MƠN KỂ TỪ KHI TỐT NGHIỆP ĐẠI HỌC: Thời gian Nơi công tác Công việc đảm nhiệm 1999-2003 Trƣờng Kỹ thuật nghiệp vụ Đƣờng sắt II Giáo viên 2004-nay Trƣờng Cao đẳng công nghệ Th đ c Giảng viên ii Luan van LỜI CAM ĐOAN Tôi cam đoan cơng trình nghiên c u c a 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 Hồ Chí Minh, ngày 20 tháng năm 2017 (Ký tên ghi r họ tên) Nguyễn Thị Phong iii Luan van CẢM TẠ Em xin chân thành cám ơn quý Thầy, Cô khoa Điện – Điện Tử trang bị cho em kiến th c tảng giúp em hồn thành tốt luận văn Cám ơn bạn lớp KDT16A chia sẻ kinh nghiệm kiến th c suốt khóa học c ng nhƣ lúc làm luận văn Đặc biệt em xin chân thành cảm ơn Thầy hƣớng dẫn, T.S Hoàng Văn D ng T.S Lê Mỹ Hà hỗ trợ em lúc thực luận văn Học viên Nguyễn Thị Phong iv Luan van TÓM TẮT Phát đối tƣợng xác định diện c a đối tƣợng cụ thể c ng nhƣ xác định vị trí c a đối tƣợng Ba giai đoạn hệ thống phát đối tƣợng gồm trích rút đặc trƣng cụ thể từ đối tƣợng mẫu; Xây dựng mơ hình phân loại đối tƣợng theo mẫu xây dựng phát hiện, nhận dạng xác đối tƣợng vị trí ảnh video Phát ngƣời ch đề thu hút ý nghiên c u ng dụng đa dạng c a Đề tài nghiên c u phát ngƣời (upright people) dựa theo phƣơng pháp trƣợt cửa sổ (sliding window) để phát ngƣời ảnh tĩnh video Trích rút đặc trƣng HOG (Histogram of Oriented Gradients) từ đối tƣợng mẫu; dùng thuật toán SVM (Support Vector Machines) để thực phân loại Để tăng tốc độ hệ thống, dùng phƣơng pháp mô tả đặc trƣng HOG cải thiện tính nhanh mơ tả đặc trƣng HOG Cuối cùng, đề xuất ng dụng phát ngƣời vào mơ hình hệ thống nhận dạng cảnh báo an ninh Luận văn gồm bốn chƣơng: Chƣơng 1: Tổng quan Chƣơng 2: Cơ sở lý thuyết Chƣơng 3: Thực nghiệm - Đánh giá Chƣơng 4: Kết luận hƣớng phát triển v Luan van hist_size = block_size*block_size*n_bins; descriptor_size = hist_size*(n_v_cells-block_size+desp)*(n_h_cellsblock_size+desp); H = zeros(descriptor_size, 1); col = 1; row = 1; % H = []; while row = 0.1 ok = ok + 1; true_positives = true_positives + 1; else ko = ko + 1; false_negatives = false_negatives + 1; % saving hard image for further retrain if safe [~, name, ext] = fileparts(positive_images(i).name); saving_path = [images_path,'/hard_examples/false_neg/', P9 Luan van name, '_n_wind_',num2str(l), ext]; % writting image imwrite(windows(:,:,:,l), saving_path); end end end end % hog extraction elapsed time pos_elapsed_time = toc(pos_start_time); fprintf('Elapsed time to classify positive images: %f seconds.\n',pos_elapsed_time); % ==================================================================== %% Reading all NEGATIVE images & computing the descriptor % Exhaustive search for hard examples % (space-scaled 64x128 windows) % ==================================================================== num_neg_images = size(negative_images,1); if strcmp(neg_method, 'pyramid') num_neg_windows = get_negative_windows_count(negative_images); elseif strcmp(neg_method, 'windows') num_neg_windows = num_neg_images*neg_chunk_size; end fprintf('testing with %d negative images and %d negative windows\n', num_neg_images,num_neg_windows); %% Computing HOG descriptor for all images (in chunks) neg_start_time = tic; false_positives = 0; true_negatives = 0; i = 0; while i < numel(negative_images) %% window obtaintion % All pyramid HOGS if strcmp(neg_method, 'pyramid') I = imread(negative_images(i+1).name); %% temporal [h,w,~] = size(I); if max(h,w) >= 160 ratio = max(96/w,160/h); I = imresize(I,ratio); end %% fin temporal [hogs, windows, wxl] = get_pyramid_hogs(I, descriptor_size, scale, stride); P10 Luan van labels = ones(size(hogs,1),1).*(-1); i = i+1; % random window HOG elseif strcmp(neg_method,'windows') this_chunk = min(neg_chunk_size, numel(negative_images)-i); windows = uint8(zeros(height,width,depth,this_chunk)); hogs = zeros(this_chunk, descriptor_size); labels = ones(size(hogs,1),1).*(-1); for l=1:this_chunk I = imread(negative_images(i+1).name); windows(:,:,:,l) = get_window(I,width,height, 'center'); hogs(l,:) = compute_HOG(windows(:,:,:,l),cell_size,block_size,n_bins); i = i+1; end end % just for fixing GUI freezing due to unic thread MatLab issue drawnow; %% prediction [predict_labels, ~, probs] = svmpredict(labels, hogs, model, '-b 1'); %% updating statistics for l=1:size(predict_labels) predict_label = predict_labels(l); if probs(l,1) < 0.1 ok = ok + 1; true_negatives = true_negatives + 1; else ko = ko + 1; false_positives = false_positives + 1; if safe % saving hard image for further retrain [~, name, ext] = fileparts(negative_images(i).name); if strcmp(neg_method, 'pyramid') [level, num_image] = get_window_indices(wxl, l); saving_path = [images_path,'/hard_examples/false_pos/', name, '_l',num2str(level), '_w',num2str(num_image),ext]; else saving_path = [images_path,'/hard_examples/false_pos/', name, '_n_wind_',num2str(l), ext]; end % writting image imwrite(windows(:,:,:,l), saving_path); P11 Luan van end end end end % hog extraction elapsed time neg_elapsed_time = toc(neg_start_time); fprintf('Elapsed time to classify negative images: %f seconds.\n',neg_elapsed_time); %% Printing gloabl results precision = true_positives/(true_positives+false_positives); recall = true_positives/(true_positives+false_negatives); fprintf('oks: %d \n',ok) fprintf('kos: %d \n',ko) fprintf('false positives: %d \n',false_positives) fprintf('false negatives: %d \n',false_negatives) fprintf('true positives: %d \n',true_positives) fprintf('true negatives: %d \n',true_negatives) fprintf('mis rate: %d \n',false_negatives / (true_positives + false_negatives)) fprintf('fppw: %d \n',false_positives / (ok + ko)) fprintf('Precision: %d \n',precision) fprintf('Recall: %d \n',recall) fprintf('F score: %d \n',2*((precision*recall)/(precision+recall))) % preparing values to return statistics = containers.Map; statistics('oks') = ok; statistics('kos') = ok; statistics('fp') = false_positives; statistics('tp') = true_positives; statistics('fn') = false_negatives; statistics('tn') = true_negatives; statistics('miss_rate') = false_negatives / (true_positives + false_negatives); statistics('fppw') = false_positives / (ok + ko); statistics('precision') = precision; statistics('recall') = recall; statistics('fscore') = 2*((precision*recall)/(precision+recall)); % -%% Aux function to obtain the test parameters % -function get_test_params() test_params = get_params('test_svm_params'); pos_chunk_size = test_params.pos_chunk_size; neg_chunk_size = test_params.neg_chunk_size; scale = test_params.scale; stride = test_params.stride; threshold = test_params.threshold; neg_method = test_params.neg_window_method; safe = test_params.safe; neg_instances = test_params.neg_instances; P12 Luan van pos_instances = test_params.pos_instances; w_params = get_params('window_params'); depth = w_params.color_depth; width = w_params.width; height = w_params.height; desc_params = get_params('desc_params'); cell_size = desc_params.cell_size; block_size = desc_params.block_size; n_bins = desc_params.n_bins; desp = 1; n_v_cells = floor(height/cell_size); n_h_cells = floor(width/cell_size); hist_size = block_size*block_size*n_bins; descriptor_size = hist_size*(n_v_cellsblock_size+desp)*(n_h_cells-block_size+desp); ok = 0; ko = 0; end end %% Aux function to know how many windows we'll have function count = get_negative_windows_count(negative_images) % computing number of levels in the pyramid count = 0; for i=1:numel(negative_images) I = imread(negative_images(i).name); %% temporal [h,w,~] = size(I); if max(h,w) >= 160 ratio = max(96/w,160/h); I = imresize(I,ratio); end %% fin temporal [~, windows] = get_pyramid_dimensions(I); count = count + windows; end end %% Aux function to know how the windows indices function [level, num_window] = get_window_indices(wxl, w_linear_index) accum_windows = 0; for i=1:size(wxl,2) accum_windows = accum_windows + wxl(i); if w_linear_index = 0.995); % positive match information coordinates = coordinates'; coordinates = coordinates(pos_indxs,:); probs = probs(pos_indxs,:); %% Computing level coordinates for drawing [bb_size, l0_coordinates] = compute_level0_coordinates(wxl, coordinates, pos_indxs, scale); %% Showing all positive windows in separate figures P14 Luan van if show_all windows = windows(:,:,:,pos_indxs); for w=1:size(pos_indxs,2) figure('name',sprintf('x=%d, y=%d', l0_coordinates(w,1),l0_coordinates(w,2))); % figure('name',sprintf('x=%d, y=%d', bb_size(w,1),bb_size(w,2))); ii = insertText(windows(:,:,:,w), [1,1], probs(w), 'FontSize',9,'BoxColor', 'green'); imshow(ii) end end %% Drawing detections over the original image draw = I; shape_inserter = other_shapeInserter; if ~draw_all shape_inserter = ok_shapeInserter; %% non-max-suppression! max_indxs = non_max_suppression(l0_coordinates, probs, bb_size); pos_indxs = pos_indxs(max_indxs); l0_coordinates = l0_coordinates(max_indxs,:); bb_size = bb_size(max_indxs, :); probs = probs(max_indxs,:); end draw = I; for w=1:size(pos_indxs,2) %% Drawing the rectangle on the original image x = l0_coordinates(w,1); y = l0_coordinates(w,2); % Rectangle conf bb_height = bb_size(w,1); bb_width = bb_size(w,2); rectangle = int32([x,y,bb_width,bb_height]); draw = step(shape_inserter, draw, rectangle); draw = insertText(draw, [x,y+bb_height], probs(w), 'FontSize',9,'BoxColor', 'green'); end % Showing image with all the detection boxes imshow(draw); figure(gcf); end %% Aux function to compute the windows coordiantes at level pyramid image function [bb_size, new_cords] = compute_level0_coordinates(wxl, coordinates, inds, scale) P15 Luan van % Consts bb_width = 64; bb_height = 128; % Vars new_cords = zeros(size(inds,2),2); bb_size = zeros(size(inds,2),2); % for each positive window index for i=1:size(inds,2) % linear index of the window ind = inds(i); % find the positive window original level level = 0; while ind > sum(wxl(1:level)) level = level + 1; end % fprintf('Match found at level %d\n', level); % compute original coordinates in Level0 image factor = (scale^(level-1)); new_cords(i,1) = floor(coordinates(i,1) * factor); new_cords(i,2) = floor(coordinates(i,2) * factor); % Bounding Box resizing? bb_size(i,1) = ceil(bb_height*factor); bb_size(i,2) = ceil(bb_width*factor); end end ///////////////////////////////////////////////////////// sliding_detector.m function sliding_detector(model) path = uigetdir('.\images','Select positive test image path'); if isa(path,'double') cprintf('Errors','Invalid paths \nexiting \n\n') return end images = rdir(strcat(path,filesep,'*.png')); for i=1:numel(images) file_name = images(i).name; disp(file_name); I = imread(file_name); [h,w,~] = size(I); scale = min(w/86, h/142); I = imresize(I, 1.2/scale); draw_sliding_window(I,model); end end P16 Luan van CODE PHÁT HIỆN NGƢỜI TRONG VIDEO Phong_nhandang.m %% Nhan dang nguoi video video=VideoReader('E:\PROJECT_VIDEO\VIDEO\video1.MP4'); nFrames=video.NumberOfFrames; % frame = read(video,[1 10]); fprintf('Totally, there are %d frames \n',nFrames); % j=1; h = figure; for ind=1:1:nFrames img=read(video,ind); img=imresize(img,1.5); peopleDetector = vision.PeopleDetector; ClassificationModel = 'UprightPeople_128x64'; ClassificationThreshold = 3; MinSize = []; MaxSize = []; ScaleFactor = 1.05; WindowStride = [8 8]; MergeDetections = true; UseROI = false; [bbox,score] = step(peopleDetector,img); % Detect people using the people detector object [selectedBbox, selectedScore] = selectStrongestBbox(bbox, score); img = insertObjectAnnotation(img,'rectangle', selectedBbox, cellstr(num2str(selectedScore)), 'Color', 'y'); figure(h); imshow(img); hold on hold off %refresh(h); %pause(0.1); I = getframe(h); imwrite(I.cdata,strcat('Output\image1(',num2str(ind),').jpg')); end % close(video); P17 Luan van S K L 0 Luan van ... KỸTHUẬT THUẬTNHẬN PHÁTDẠNG HIỆN ÁP NGƢỜI TRONG HỆ THỐNG SÁT AN NINH TRONG GIÁMGIÁM SÁT AN NINH NGÀNH: KỸ THUẬT ĐIỆN TỬ - 60520203 NGÀNH: KỸ THUẬT ĐIỆN TỬ Tp Hồ Chí Minh, tháng 10/2017 Luan van... HỌC HỌC SƢ SƢ PHẠM PHẠM KỸ KỸ THUẬT THUẬT TRƢỜNG THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ NGUYỄN THỊ PHONG ỨNG DỤNG KỸ THUẬT PHÁT HIỆN NGƢỜI TRONG GIÁM SÁT AN NINH NGÀNH: KỸ THUẬT ĐIỆN TỬ - 60520203... PHẠMKỸ KỸTHUẬT THUẬT TRƢỜNG THÀNHPHỐ PHỐHỒ HỒCHÍ CHÍMINH MINH THÀNH CHUYÊN ĐỀ LUẬN VĂN LUẬN VĂN THẠC SĨ THẠC SĨ NGUYỄN THỊNGUYỄN PHONG THỊ PHONG HỌ VÀ TÊN HỌC VIÊN: NGHIÊN CỨU KỸ DỤNG ỨNG DỤNG KỸTHUẬT

Ngày đăng: 02/02/2023, 10:02

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

Tài liệu liên quan