Shahar chorrahalarida boshqarishni optemallashtirish dasturini ishlab chiqish



Yüklə 0,98 Mb.
səhifə6/7
tarix24.04.2023
ölçüsü0,98 Mb.
#102054
1   2   3   4   5   6   7
Xaydarov Sherali (Shahar chorrahalarida)

from tkinter import *
import time
root = Tk()
root.title("Svetofor")
canvas = Canvas(root, width=300, height=500)
canvas.pack()
while True:
canvas.delete("barchasi")
canvas.create_oval(50, 50, 250, 250, fill="qora")
canvas.create_oval(50, 250, 250, 450, fill="qora")
canvas.create_oval(75, 75, 225, 225, fill="qizil")
canvas.create_oval(75, 275, 225, 425, fill="yashil")
root.update()
time.sleep(5)
canvas.delete("all")
canvas.create_oval(50, 50, 250, 250, fill="qora")
canvas.create_oval(50, 250, 250, 450, fill="qora")
canvas.create_oval(75, 75, 225, 225, fill="sariq")
canvas.create_oval(75, 275, 225, 425, fill="qora")
root.update()
time.sleep(2)
canvas.delete("barchasi")
canvas.create_oval(50, 50, 250, 250, fill="qora")
canvas.create_oval(50, 250, 250, 450, fill="qora")
canvas.create_oval(75, 75, 225, 225, fill="qora")
canvas.create_oval(75, 275, 225, 425, fill="ko’k")
root.update()
time.sleep(5)
2-dastur kodi
Bu kod "root" nomli bosh objekt yaratadi va unga "Svetofor" nomi beriladi. Keyin, "canvas" nomli yangi obyekt yaratiladi va unga oyna o'lchami beriladi. While sikli yordamida, svetofor yaratiladi [8]. Birinchi turda, yashirin cheklovi ishga tushiriladi, keyin sariq cheklovi, yana keyin ko'k cheklovi. Barcha cheklovlar bir-biridan farqli ranglarda chizilgan. Har bir cheklov turida, "canvas.create_oval" yordamida "oval" yaratiladi. "canvas.delete" yordamida barcha avlod kompyuterlarida ishlash imkonyatini yaratadi. Yuqorida tavsiflangan aqlli avtomatlashtirilgan tizimdan transportni boshqarish va shahar chorrahalarida, jumladan, shahar transport vositalarini boshqarishda, tirbandlikni kamaytirish va shaharda harakat samaradorligini oshirish uchun qulay imkoniyat beradi. Biroq, bunday tizimni ishlab chiqish va amalga oshirish uchun katta sarmoya va barcha manfaatdor tomonlar, jumladan, davlat organlari va shaharda yo'l infratuzilmasi va transport boshqaruvi uchun mas'ul bo'lgan kommunal xizmatlar bilan kelishuv talab etiladi. Bundan tashqari, tizimning samarali ishlashi uchun chorrahalar va shahar yo‘llarida kameralar va datchiklar kabi qo‘shimcha uskunalar o‘rnatish zarur bo‘lishi mumkin. Har qanday holatda ham, shahar chorrahalarida avtotransport vositalarini moslashuvchan boshqarishning intellektual avtomatlashtirilgan tizimini ishlab chiqish va joriy etish tirbandlikni kamaytirish, yo‘l harakati xavfsizligini oshirish va atmosferaga zararli chiqindilarni kamaytirishda muhim qadam bo‘lishi mumkin. Harakatni boshqarish algoritmlarini ishlab chiqishda yo‘l harakati mutaxassislari ham ishtirok etishlari mumkin, ular chorrahalarda harakatni optimallashtirish va yo‘l harakati xavfsizligini yaxshilash bo‘yicha o‘z tavsiyalarini berishlari mumkin [9]. Bundan tashqari, transport oqimini boshqarish va tirbandlikni kamaytirishda muvaffaqiyatli tajribaga ega bo'lgan boshqa shaharlarda qo'llaniladigan allaqachon mavjud usullar va amaliyotlar transportni boshqarish algoritmlarini ishlab chiqish uchun ishlatilishi mumkin.
import cv2
import numpy as np
# web camera
cap = cv2.VideoCapture('video.mp4')
min_width_react=80 # bo'yi
min_hieght_react=80 # eni
count_line_postion = 550
# tanlash
algo = cv2.bgsegm.createBackgroundSubtractorMOG()
def center_handle(x,y,w,h):
x1 = int(w/2)
y1 = int(h/2)
cx = x + x1
cy = y + y1
return cx, cy
detect = []
offset = 6 # allowable error between pixcel
counter = 0
while True:
ret, frame1 = cap.read()
grey = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(grey,(3,3),5)
#applying on each frame
img_sub = algo.apply(blur)
dilat = cv2.dilate(img_sub, np.ones((5,5)))
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))
dilatada = cv2.morphologyEx(dilat, cv2.MORPH_CLOSE, kernel)
dilatada = cv2.morphologyEx(dilatada, cv2.MORPH_CLOSE, kernel)
counterSahpe,h = cv2.findContours(dilatada, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cv2.line(frame1, (25, count_line_postion),(1200, count_line_postion),(255,127,0),3)
for (i,c) in enumerate(counterSahpe):
(x,y,w,h) = cv2.boundingRect(c)
validate_counter = (w>= min_width_react) and (h>=min_hieght_react)
if not validate_counter:
continue
cv2.rectangle(frame1,(x,y),(x+w, y+h), (0,255,0),2)
cv2.putText(frame1, "Avtomabellar soni :"+str(counter),(x,y-20), cv2.FONT_HERSHEY_TRIPLEX,1,(255,244,0),2)
center = center_handle(x,y,w,h)
detect.append(center)
cv2.circle(frame1, center,4,(0,0,255), -1)
for (x,y) in detect:
if y<(count_line_postion + offset) and y > (count_line_postion - offset):
counter+=1
cv2.line(frame1, (25, count_line_postion),(1200, count_line_postion), (0,127,255),3)
detect.remove((x,y))
print("Avtomabellar soni:"+str(counter))
cv2.putText(frame1, "Avtomabellar soni :" + str(counter), (450,70), cv2.FONT_HERSHEY_SIMPLEX, 2,(0,0,255),5)
#cv2.imshow('Detecter',dilatada)
cv2.imshow('Video Original',frame1)
if cv2.waitKey(1) == 13:
break
cv2.destroyAllWindows()
cap.release()
3-darstur kodi

1-rasm(dastur ishlashi)
Xulosa qilib aytganda harakatni boshqarish algoritmlarini ishlab chiqish shahar chorrahalarida avtotransport vositalarini moslashuvchan boshqarishning intellektual avtomatlashtirilgan tizimini yaratishda muhim qadam bo‘lib, transport oqimini yanada samarali boshqarish va tirbandlikni kamaytirishga xizmat qiladi.

Yüklə 0,98 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin