Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fps counter added #579

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Object_detection_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@
# Open video file
video = cv2.VideoCapture(PATH_TO_VIDEO)

#additional_code
start_time = time.time()
flag=0

while(video.isOpened()):

start = time.time()
flag = flag + 1

# Acquire frame and expand frame dimensions to have shape: [1, None, None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
ret, frame = video.read()
Expand All @@ -113,6 +120,11 @@
use_normalized_coordinates=True,
line_thickness=8,
min_score_thresh=0.60)

#Shows the fps in the terminal
cv2.imshow('Object detector', frame)
fps1 = 1/(time.time() - start)
print("fps: ",fps1)

# All the results have been drawn on the frame, so it's time to display it.
cv2.imshow('Object detector', frame)
Expand All @@ -121,6 +133,11 @@
if cv2.waitKey(1) == ord('q'):
break

#Average fps
end_time = time.time()
fps = flag/(end_time - start_time)
print("Average FPS: ",fps)

# Clean up
video.release()
cv2.destroyAllWindows()