Use OpenCV

Display an OpenCV Window Using cv2.waitkey

The cv2.waitkey method allows you to display a window that has been shown with the cv2.imshow method for a specified period of time.

You can use the following code to display a frame until a key is pressed:


The cv2.waitkey(0)  method is commonly used in video capture scripts to maintain a continuous window on which the latest frame can appear.

You can use the following code to display a frame for a certain number of milliseconds:


Next steps

OpenCV can be used with the open source supervision Python package.

supervision provides an extensive range of functionalities for working with computer vision models. With supervision, you can:

1. Process and filter detections and segmentation masks from a range of popular models (YOLOv5, Ultralytics YOLOv8, MMDetection, and more).
2. Process and filter classifications.
3. Compute confusion matrices.

And more! To learn about the full range of functionality in supervision, check out the supervision documentation.