Skip to content

Instantly share code, notes, and snippets.

@kefir-
Last active July 26, 2023 05:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kefir-/03cea3e3b17b7a74a7cdcf57a2159a79 to your computer and use it in GitHub Desktop.
Save kefir-/03cea3e3b17b7a74a7cdcf57a2159a79 to your computer and use it in GitHub Desktop.
Python cv2 show image in window with correct size
#!/usr/bin/env python
import cv2
c = cv2.imread('ketil.jpg')
height, width = c.shape[:2]
cv2.namedWindow('jpg', cv2.WINDOW_NORMAL)
cv2.resizeWindow('jpg', width, height)
cv2.imshow('jpg', c)
r = cv2.waitKey(0)
print "DEBUG: waitKey returned:", chr(r)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment