-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
77 lines (59 loc) · 2.15 KB
/
main.py
File metadata and controls
77 lines (59 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import cv2
import time
import sys
from gstream import VideoGStreamer
from flaskstream import VideoFStreamer
from opencv import OpenCV
Width=1280
Height=720
FPS_input=30
Colors_input = False
FPS_output=30
Colors_output = True
Stream = 'G'
if input("Default : Def_in: {1}x{2}, FPS_in: {3}, Colors_in: {4} \n Stream: {5}, FPS_out: {6}, Colors_out: {7} \n (y/n): ")=='n':
Width = input("Width: ")
Height = input("Height: ")
FPS_input = input("FPS_in: ")
Colors_input = input("Colors_in (y/n): ")=='y'
FPS_output = input("FPS_output: ")
Colors_output = input("Colors_output (y/n) : ")=='y'
Stream = input("Stream (G for gstreamer / F for flask / N for none): ")
if Stream=="F" or Stream=="f":
streamer = VideoFStreamer(width=Width, height=Height, fps_input=FPS_input, colors_input=Colors_input,stream=Stream, fps_output=FPS_output, colors_output=Colors_output)
else:
streamer = VideoGStreamer(width=Width, height=Height, fps_input=FPS_input, colors_input=Colors_input,stream=Stream, fps_output=FPS_output, colors_output=Colors_output)
print("Traitement démarré... ctrl+C pour stopper")
prev_time = time.time()
frame_count = 0
fps=0
cv = OpenCV() #Added
try:
while True:
ret, frame = streamer.read()
if not ret:
break
#frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #conversion niveaux de gris
frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)
# --- TRAITEMENT OPENCV ---
cv.Aruco(frame, fps) #added
"""
cv2.putText(frame, f"Pi4 - Detection Active - FPS {fps}",
(50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
# --- FIN DU TRAITEMENT OPENCV ---
"""
# Streaming
if Stream!="N" or "n":
streamer.send(frame)
frame_count += 1
current_time = time.time()
if current_time - prev_time >= 1.0:
print(f"FPS Réels : {frame_count}")
fps = frame_count
frame_count = 0
prev_time = current_time
except KeyboardInterrupt:
print("\nArrêt du programme...")
sys.exit(1)
finally:
streamer.release()