Search code examples
pythonopencvvideo-capture

CV2 image and webcam always minimized when running a program


cap = cv2.VideoCapture(0)

and

img = cv2.imread(/users/..../jumpingjacks.jpeg, 1)
cv2.imshow('Jumping Jacks', img)

when my prog run these two codes, the webcam feed and image doesn't pop out, but instead, it shows as minimized version, which requires me to press the icon at the bottom of the screen to bring it forward. anyidea what caused this ?


Solution

  • Found the answer by trying out this code:

    img = cv2.imread('/users/..../jumpingjacks.jpeg', 1)
    cv2.imshow('Jumping Jacks', img)
    cv2.setWindowProperty("Jumping Jacks", cv2.WND_PROP_TOPMOST, 1)
    cv2.waitKey(5000)
    cv2.destroyAllWindows()