added FPS display

This commit is contained in:
2024-07-15 11:45:11 +02:00
parent 201b8d14a4
commit 369ebacfef
2 changed files with 22 additions and 9 deletions
+19 -6
View File
@@ -38,6 +38,8 @@ picam2 = Picamera2()
pprint(picam2.sensor_modes)
settings = {'NoiseReductionMode': 0, 'AeExposureMode': 0, 'ExposureTime': 10000, 'AnalogueGain': 1, 'FrameRate': picam2.sensor_modes[0]['fps']}
caps = {"FrameRate": (1, picam2.sensor_modes[0]['fps'], None)}
timer = None
def load_settings():
_result = None
@@ -76,14 +78,25 @@ def get_value(item: str):
return picam2.camera_controls[item]
def process(request):
colour = (0, 255, 0)
origin = (0, 30)
font = cv2.FONT_HERSHEY_SIMPLEX
scale = 1
thickness = 2
global timer
fps = 0
timestamp = time.strftime("%Y-%m-%d %X")
# Calculate Frames per second (FPS)
if timer is not None:
fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer)
with MappedArray(request, "main") as m:
cv2.putText(m.array, timestamp, origin, font, scale, colour, thickness)
# Display timestamp on frame
cv2.putText(m.array, timestamp, (0, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
# Display FPS on frame
cv2.putText(m.array, "FPS : " + str(int(fps)), (20, m.array.shape[0] - 20), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 240, 0), 2)
# Start timer
timer = cv2.getTickCount()
if __name__ == '__main__':
for item in items:
+3 -3
View File
@@ -1,7 +1,7 @@
{
"NoiseReductionMode": 0,
"AeExposureMode": 0,
"ExposureTime": 19029,
"AnalogueGain": 1,
"FrameRate": 25.000000000000007
"ExposureTime": 12829,
"AnalogueGain": 5.0,
"FrameRate": 10.380000000000003
}