drobne poprawki i dodatkowy plik video
This commit is contained in:
parent
999559aa6a
commit
ed451efcec
BIN
data/video_3.mp4
Normal file
BIN
data/video_3.mp4
Normal file
Binary file not shown.
17
main.py
17
main.py
@ -7,7 +7,7 @@ counter_up=0 #licznik pojazdow jadacych w gore
|
||||
counter_down=0 #licznik pojazdow jadacych w dol
|
||||
|
||||
while True:
|
||||
user_choice = input("Wybierz nagranie:\n1. video_1.mp4\n2. video_2.avi\n")
|
||||
user_choice = input("Wybierz nagranie:\n1. video_1.mp4\n2. video_2.avi\n3. video_3.mp4\n")
|
||||
if user_choice == "1":
|
||||
input_video = 'data/video_1.avi'
|
||||
vid_name = 'video_1'
|
||||
@ -18,6 +18,13 @@ while True:
|
||||
vid_name = 'video_2'
|
||||
kernelSize = 3
|
||||
break
|
||||
elif user_choice == "3":
|
||||
input_video = 'data/video_3.mp4'
|
||||
vid_name = 'video_3'
|
||||
kernelSize = 3
|
||||
break
|
||||
|
||||
|
||||
|
||||
cap = cv2.VideoCapture(input_video)
|
||||
|
||||
@ -133,10 +140,10 @@ while(cap.isOpened()):
|
||||
new = False
|
||||
i.updateCoords(cx, cy)
|
||||
#sprawdz czy prekroczyl mete
|
||||
if i.going_UP(lineLower,lineUpper) == True:
|
||||
if i.going_UP(lineUpper) == True:
|
||||
counter_up+=1
|
||||
print("Pojazd o ID:",i.getId(),'przekroczyl linie mety w gore o czasie:', time.strftime("%c"))
|
||||
elif i.going_DOWN(lineLower,lineUpper) == True:
|
||||
elif i.going_DOWN(lineLower) == True:
|
||||
counter_down+=1
|
||||
print("Pojazd o ID:", i.getId(), 'przekroczyl linie mety w dol o czasie:', time.strftime("%c"))
|
||||
break
|
||||
@ -174,10 +181,10 @@ while(cap.isOpened()):
|
||||
cv2.putText(frame, str_up, (10, 40), font, 0.4, lineUpper_color, 1, cv2.LINE_AA)
|
||||
cv2.putText(frame, str_down, (10, 90), font, 0.4, (255, 255, 255), 2, cv2.LINE_AA) #biale tlo zeby licznik byl wyrazniejszy
|
||||
cv2.putText(frame, str_down, (10, 90), font, 0.4, lineLower_color, 1, cv2.LINE_AA)
|
||||
frame = cv2.resize(frame, (0, 0), None, size, size) # rozmiar obrazu x2
|
||||
#frame = cv2.resize(frame, (0, 0), None, size, size) # rozmiar obrazu x2
|
||||
cv2.imshow('Frame',frame)
|
||||
|
||||
key = cv2.waitKey(60)
|
||||
key = cv2.waitKey(30)
|
||||
if key == 27: # Wyjdz po nacisnieciu escape
|
||||
break
|
||||
|
||||
|
@ -48,10 +48,10 @@ class Car:
|
||||
def timedOut(self):
|
||||
return self.done
|
||||
|
||||
def going_UP(self, mid_start, mid_end):
|
||||
def going_UP(self, finishLine):
|
||||
if len(self.tracks)>=2:
|
||||
if self.state=='0':
|
||||
if self.tracks[-1][1]<mid_end and self.tracks[-2][1]>=mid_end:
|
||||
if self.tracks[-1][1]<finishLine and self.tracks[-2][1]>=finishLine:
|
||||
self.state='1'
|
||||
self.dir='up'
|
||||
return True
|
||||
@ -62,10 +62,10 @@ class Car:
|
||||
else:
|
||||
return False
|
||||
|
||||
def going_DOWN(self,mid_start,mid_end):
|
||||
def going_DOWN(self,finishLine):
|
||||
if len(self.tracks)>=2:
|
||||
if self.state=='0':
|
||||
if self.tracks[-1][1]>mid_start and self.tracks[-2][1]<=mid_start:
|
||||
if self.tracks[-1][1]>finishLine and self.tracks[-2][1]<=finishLine:
|
||||
self.state='1'
|
||||
self.dir='down'
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user