Nghiên Cứu Hệ Thống Quan Sát Cho Xe Trong Việc Xác Định Tình Trạng Giao Thông.pdf

91 1 0
Nghiên Cứu Hệ Thống Quan Sát Cho Xe Trong Việc Xác Định Tình Trạng Giao Thông.pdf

Đ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

Untitled THÀNH PHỐ HỒ CHÍ MINH BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT Tp Hồ Chí Minh, tháng 20 SKL007929 NGÀNH CNKT Ô TÔ 14145069 NG 14145018 TRƯỜNG ĐH SƯ PHẠM KỸ THUẬT TP HỒ CHÍ MINH[.]

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 ĈӖÈ17Ӕ71*+,ӊ3 NGÀNH CNKT ễ Tễ 1*+,ầ1&8+7+1*48$16ẩ7&+2;( 7521*9,&;ẩ&1+7ẻ1+751**,$27+é1* *9+' 9ẻ1++81 697+  /ầ1*&+ặ1 14145069 NG8 1) = 1; Edge = step(hAutothreshold, I); [H, Theta, Rho] = step(hHough, Edge); % Phat hien dinh H1 = H; % Mo rong ma tran H voi theta < -78 va theta >= 78 H1(:, 1:12) = 0; H1(:, end-12:end) = 0; Idx1 = step(hLocalMaxFind1, H1); Count1 = size(Idx1,1); % Chon Rhos va Thetas tuong ung voi dinh Line = [Rho(Idx1(:, 2)); Theta(Idx1(:, 1))]; Enable = [ones(1,Count1) zeros(1, ExpLaneNum-Count1)]; % Theo doi tap hop cac dau phan cach lan duong [Rep_ref, Count_ref] = videolanematching(Rep_ref, Count_ref, 70 MaxLaneNum, ExpLaneNum, Enable, Line, TrackThreshold, frameFound+frameLost); % Chuyen duong thang tu toa Polar sang Cartesian Pts = step(hHoughLines1, Rep_ref(2,:), Rep_ref(1,:), Imlow); % Lan duong trai va phai [TwoValidLanes, NumNormalDriving, TwoLanes, OutMsg] = videodeparturewarning(Pts, Imlow, MaxLaneNum, Count_ref, NumNormalDriving, OutMsg); % Dien giai: = Right lane departure, % = Normal driving, = Left lane departure % Output Frame = Frame + 1; if Frame >= TwoLanes1 = TwoLanes + [offset; offset]'; if DrawPoly && TwoValidLanes if TwoLanes(4,1) >= 239 Templ = TwoLanes1(3:4, 1); else Templ = [0 239]'; end if TwoLanes(4,2) >= 239 Tempr = TwoLanes1(3:4, 2); else Tempr = [359 239]'; end Pts_poly = [TwoLanes1(:,1); Templ; Tempr; TwoLanes1(3:4,2); TwoLanes1(1:2,2)]; % Ve lan duong RGB = insertShape(RGB,'FilledPolygon',Pts_poly.', 'Color',[1 1],'Opacity',0.0); end % Ve duong line 71 RGB = insertShape(RGB,'Line',TwoLanes1', 'Color',{'yellow','yellow'}); % Chen text canh bao txt = warnText{OutMsg+1}; txtLoc = warnTextLoc(OutMsg+1, :); txtColor = single(warningTextColors{mod(Frame-1,4)+1}); RGB = insertText(RGB,txtLoc,txt,'TextColor', txtColor, 'FontSize',20, 'BoxOpacity', 0); %% truyen tin hieu lech trai lech phai xuong arduino thong qua serial port % lech trai if (OutMsg == 0) writeDigitalPin (a,2,1) writeDigitalPin (a,12,0) writeDigitalPin (a,13,1) writePWMVoltage (a, 3,5) pause (0.1) writeDigitalPin (a,12,0) writeDigitalPin (a,13,0) %writePWMVoltage (a,2,0) pause (0.5) writeDigitalPin (a,12,1) writeDigitalPin (a,13,0) writePWMVoltage (a, 3,5) pause(0.05) writeDigitalPin (a,12,0) writeDigitalPin (a,13,0) writePWMVoltage (a, 3,0) elseif (OutMsg == | OutMsg == 2) writeDigitalPin (a,2,0) end 72 if (OutMsg == 1) writeDigitalPin (a,4,1); writeDigitalPin (a,12,0); writeDigitalPin (a,13,0); %writePWMVoltage (a,2,0); elseif (OutMsg == | OutMsg == 2) writeDigitalPin (a,4,0) end if (OutMsg == 2) %led sang writeDigitalPin (a,8,1) %dieu khien motor writeDigitalPin (a,12,1) writeDigitalPin (a,13,0) writePWMVoltage (a,3,5) pause (0.1) writeDigitalPin (a,12,0) writeDigitalPin (a,13,0) %writePWMVoltage (a,3,0) pause (0.5) writeDigitalPin (a,12,0) writeDigitalPin (a,13,1) writePWMVoltage (a,3,5) pause(0.05) writeDigitalPin (a,12,0) writeDigitalPin (a,13,0) elseif (OutMsg == | OutMsg == 1) %led tat writeDigitalPin (a,8,0) %writePWMVoltage (a,2,0) end end 73 OutMsgPre = OutMsg; step(hVideoOut,RGB); end release(hVideoSrc); % dong giao tiep voi cong com fclose(s); B Xác định dấu phân cách trái / phải function [TwoValidLanes, NumNormalDriving, TwoLanes, OutMsg] = videodeparturewarning(Pts, Imlow, MaxLaneNum, Count_ref, NumNormalDriving, OutMsg) % hObject handle to exit_pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Dis_inf = size(Imlow, 2); % Width of image Halfwidth = Dis_inf * 0.5; Left_dis = single(intmax('int16')); Left_pts = zeros(4, 1); Right_dis = single(intmax('int16')); Right_pts = zeros(4, 1); Pts = Pts(:, [2 3])'; for i = 1:MaxLaneNum % Pick the column corresponding to the point closer to the top if Pts(1, i) >= Pts(3, i) ColNum = Pts(2, i); else ColNum = Pts(4, i); end if Count_ref(i) >= centerDis = abs(Halfwidth - ColNum); else centerDis = Dis_inf; end 74 if (Halfwidth - ColNum) >= % left lane if centerDis < Left_dis Left_dis = centerDis; Left_pts = Pts(:, i); end else % right lane if centerDis < Right_dis Right_dis = centerDis; Right_pts = Pts(:, i); end end end % Departure detection if Left_dis < Dis_inf TmpLeftPts = Left_pts; else TmpLeftPts = zeros(4, 1); end if Right_dis < Dis_inf TmpRightPts = Right_pts; else TmpRightPts = zeros(4, 1); end TwoLanes = int32([TmpLeftPts TmpRightPts]); % Check whether both lanes are valid Check1 = (TwoLanes(1,:) ~= TwoLanes(3,:)) | (TwoLanes(2,:) ~= TwoLanes(4,:)); Check2 = (abs(TwoLanes(1,:) - TwoLanes(3,:)) + abs(TwoLanes(2,:) - TwoLanes(4,:))) >= 10; TwoValidLanes = (Left_dis = OutMsg = RawMsg; end % else keep old OutMsg if RawMsg ~= int8(1) NumNormalDriving = 0; end TwoLanes = TwoLanes([2 3], :); C Xác định dấu đường function [Rep_ref, Count_ref] = videolanematching(Rep_ref, Count_ref, MaxLaneNum, ExpLaneNum, Enable, Line, TrackThreshold, CountUpperThresh) List = double(intmax('int16')) * ones(MaxLaneNum, ExpLaneNum); 76 for i = 1:MaxLaneNum for j = 1:ExpLaneNum if Count_ref(i) > && Enable(j) == List(i, j) = abs(Line(1, j)' - Rep_ref(1,i)) + abs(Line(2, j)' - Rep_ref(2, i)) * 200; end end end % Find the best matches between the current lines and those in the % repository %Match_dis Match_dis = intmax('int16')*ones(1, MaxLaneNum, 'int16'); = double(intmax('int16'))*ones(1, MaxLaneNum); Match_list = zeros(2, MaxLaneNum); for i = 1:ExpLaneNum if i > % Reset the row and column where the minimum element lies on List(rowInd, :) = double(intmax('int16')) * ones(1, ExpLaneNum); List(:, colInd) = double(intmax('int16')) * ones(MaxLaneNum, 1); end % In the 1st iteration, find minimum element (corresponds to % best matching targets) in the distance matrix Then, use the % updated distance matrix where the minimun elements and their % corresponding rows and columns have been reset [Val, Ind] = min(List(:)); [rowInd colInd] = ind2sub(size(List), Ind); Match_dis(i) = Val; Match_list(:,i) = [rowInd colInd]'; end % Update reference target list % If a line in the repository matches with an input line, replace % it with the input one and increase the count number by one; % otherwise, reduce the count number by one The count number is % then saturated Count_ref = Count_ref - 1; 77 for i = 1:ExpLaneNum if Match_dis(i) > TrackThreshold % Insert in an unused space in the reference target list NewInd = find(Count_ref < 0, 1); Rep_ref(:, NewInd) = Line(:, Match_list(2, i)); Count_ref(NewInd) = Count_ref(NewInd) + 2; else % Update the reference list Rep_ref(:, Match_list(1, i)) = Line(:, Match_list(2, i)); Count_ref(Match_list(1, i)) = Count_ref(Match_list(1, i)) + 2; end end Count_ref(Count_ref < 0) = 0; Count_ref(Count_ref > CountUpperThresh) = CountUpperThresh; D Code Arduino // them thu vien va khai bao cac chan cua cam bien sieu am #include #define TRIGGER_PIN 12 #define ECHO_PIN 13 #define MAX_DISTANCE 300 #define led_distance 11 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); void setup() { Serial.begin(115200); pinMode (led_distance,OUTPUT); } void loop() { delay(1000); //Serial.print("Ping: "); Serial.println(sonar.ping_cm()); // Serial.println("cm"); if ( sonar.ping_cm () 20) { digitalWrite(led_distance ,LOW); } } 79 S K L 0

Ngày đăng: 21/06/2023, 20:08

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

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

Tài liệu liên quan