Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
asd
  • Loading branch information
ronildofacanha committed May 12, 2022
1 parent f6a324a commit 8fe074f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
29 changes: 19 additions & 10 deletions D_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import time
import threading
import math

tempoGB = 0
statusSemaforo = 'null'
extent = False
Expand Down Expand Up @@ -40,17 +39,17 @@ def Calculating_time_extent(classes):
global extent
global semaforoAberto

if tempoGB == 0 and tempoGB < 10:
tempoGB = 10
if tempoGB == 0 and tempoGB < 20:
tempoGB = 20
extent = False
t1 = threading.Thread(target=thread_delay, args=(0,))
t1.start()
print("TEMPO: PESSOA ", tempoGB)
# Text = 'TEMPO PARA PESSOA: '
# cv2.putText(frame, Text+str(tempoGB)+'s', (0, 25),
# cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 150, 0), 3)
if classes == "chair" and extent == False and tempoGB < 15:
tempoGB += 5
if classes == "chair" and extent == False and tempoGB < 30:
tempoGB += 10
print("TEMPO: CADEIRANTE ", tempoGB)
extent = True
# cv2.putText(frame, Text+str(tempoGB)+'s', (0, 25),
Expand Down Expand Up @@ -133,13 +132,13 @@ def createBoxes(_img, i, _confidences, _boxes, _COLORS, _LABELS, _AllClassesID):
# CAPTURA FRAME A FRAME
def DetectionX():
# ARQUIVOS
input_file = 'arquivos/carros1.mp4'
input_file = 'arquivos/lv1.mp4'
weights_path = 'arquivos/yolov4-tiny.weights'
cfg_path = 'arquivos/yolov4-tiny.cfg'
names_path = 'arquivos/coco.names'
# CONFIG PRECISÃO
threshold = 0.6 # Nivel de confiança?
threshold_NMS = 0.6
threshold = 0.3 # Nivel de confiança?
threshold_NMS = 0.4
font_smal, font_big = 0.4, 0.6
font_tipe = cv2.FONT_HERSHEY_SIMPLEX
fontLine = 2 # inteiro
Expand Down Expand Up @@ -194,6 +193,7 @@ def DetectionX():

if len(objects) > 0:
for i in objects.flatten():

Calculating_time_extent(LABELS[AllClassesID[i]])

if semaforoAberto:
Expand All @@ -205,12 +205,21 @@ def DetectionX():

cv2.putText(_frame, "TEMPO: "+str(count)+'s', (0, 25),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 150, 0), 3)
cv2.putText(_frame, "SEMAFORO: "+str(semaforoAberto), (0, 50),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 150), 2)
cv2.putText(_frame, "SEMAFORO: "+str(semaforoAberto), (0, 60),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)

# t1 = threading.Thread(target=thread_delay, args=(5,))
# t1.start()
# print(tempoGB)
if semaforoAberto:
semaforoImage = cv2.imread("arquivos/sTrue.png")
cv2.putText(_frame, "N DETECCOES: "+str(len(AllBoxes)), (0, 100),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)

else:
semaforoImage = cv2.imread("arquivos/sFalse.png")
cv2.imshow('SEMAFORO', semaforoImage)

imageShow(_frame)


Expand Down
12 changes: 6 additions & 6 deletions D_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import time

# ARQUIVOS
input_file = 'arquivos/carros1.mp4'
input_file = 'arquivos/s1.mp4'
weights_path = 'arquivos/yolov4-tiny.weights'
cfg_path = 'arquivos/yolov4-tiny.cfg'
names_path = 'arquivos/coco.names'
# CONFIG PRECISÃO
threshold = 0.8 # Nivel de confiança?
threshold_NMS = 0.3
threshold = 0.3 # Nivel de confiança?
threshold_NMS = 0.2
font_smal, font_big = 0.4, 0.6
font_tipe = cv2.FONT_HERSHEY_SIMPLEX
fontLine = 2 # inteiro
Expand Down Expand Up @@ -72,7 +72,7 @@ def blobImage(net, img):
net.setInput(blob)
layer_Outputs = net.forward(ln)
end = time.time()
print("[TEMPO DE DETECÇÃO] {:.2f} seconds".format(end - start))
#print("[TEMPO DE DETECÇÃO] {:.2f} seconds".format(end - start))
return net, img, layer_Outputs


Expand Down Expand Up @@ -151,8 +151,8 @@ def createBoxes(_img, i, _confidences, _boxes, _COLORS, _LABELS, _AllClassesID):
_frame, i, AllConfidences, AllBoxes, COLORS, LABELS, AllClassesID)
objects = imageCopy[y:y+h, x:x+w]

cv2.putText(_frame, "PROCSSAMENTO {:.2f}s".format(time.time()-t),
(20, video_height-20), font_tipe, font_big, (255, 255, 255), fontLine, lineType=cv2.LINE_AA)
# cv2.putText(_frame, "PROCSSAMENTO {:.2f}s".format(time.time()-t),
# (20, video_height-20), font_tipe, font_big, (255, 255, 255), fontLine, lineType=cv2.LINE_AA)

cv2.imshow("frame", _frame)

Expand Down

0 comments on commit 8fe074f

Please sign in to comment.