Display
Now we’re at the final module of the main loop, where we build the final window. In this window, we display the FPS counter and the camera image.
In this module we are dealing with the following code snippet of the Engine Loop:
mainmethod1def main(self): 2 3 ... 4 5 self.fps_setter() 6 self.window.window_show(self.camera_model) 7 8 ...
Let’s dive into the detailed explanations of the implementation.
self.fps_setter()
In this line, we set our final fps counter.
- fps_setter()
Updates and displays the current frames per second (FPS) on the camera image.
fps_settermethoddef fps_setter(self): fps = self.fps_counter.get_fps_filtered() cv.putText(self.camera_model.camera_image, f"FPS: {fps:.0f}", (10, 30), cv.FONT_HERSHEY_PLAIN, 1.2, (0, 255, 0), 1)
- window_show()
The method displays the current frame of the camera using the cv2 libary.
window_showmethoddef window_show(self, class_cam): cv.imshow("image window", class_cam.camera_image) cv.waitKey(1)