added fps display
This commit is contained in:
+10
-1
@@ -287,6 +287,8 @@ if __name__ == '__main__':
|
||||
|
||||
key_wait = -1
|
||||
while True:
|
||||
# Start timer
|
||||
timer = cv2.getTickCount()
|
||||
# Read a new frame
|
||||
ok, image = video.read()
|
||||
if ok:
|
||||
@@ -296,8 +298,15 @@ if __name__ == '__main__':
|
||||
mean_distance = ct.process(image, image_anno)
|
||||
if mean_distance is not None:
|
||||
cv2.putText(image_anno, f"Distance [{i}] : ({mean_distance[0]:+05.2f}, {mean_distance[1]:+05.2f})",
|
||||
(20, 25 + 25 * i), cv2.FONT_HERSHEY_SIMPLEX, 0.5, ct.color, 1)
|
||||
(20, 20 + 20 * i), cv2.FONT_HERSHEY_SIMPLEX, 0.5, ct.color, 1)
|
||||
i += 1
|
||||
|
||||
# Calculate Frames per second (FPS)
|
||||
fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer)
|
||||
# Display FPS on frame
|
||||
cv2.putText(image_anno, "FPS : " + str(int(fps)), (20, image_anno.shape[0] - 20),
|
||||
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (50, 170, 50), 1)
|
||||
|
||||
cv2.imshow(f"Image Anno", image_anno)
|
||||
else:
|
||||
video.set(cv2.CAP_PROP_POS_FRAMES, 0)
|
||||
|
||||
Reference in New Issue
Block a user