Use OpenCV

Open Images with imread

You can use the imread function to read an image from a file.

According to OpenCV, the imread function supports:

  • Winows bitmaps
  • JPEG files
  • JPEG 2000 files
  • PNG
  • WebP
  • Portable image format
  • Sun rasters
  • TIFF files
  • OpenEXT images
  • Radiance HDR images
  • Raster and vector geospatial data

To open a file, first import the cv2  library, then use the following code:

image = cv2.imread("image.jpeg")

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.