Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Should destroyAllWindows and release functions be used in Python?

Hi, i wrote a simple script to read frames from webcam

import cv2
cv2.destroyAllWindows()
capture = cv2.VideoCapture(0,cv2.CAP_DSHOW)
while (True):
    ret, frame = capture.read()
    cv2.imshow('video', frame)
    if cv2.waitKey(30) == 27:
        break
capture.release()
cv2.destroyAllWindows()

In this document, any many other codes i have seen, these two functions have used

capture.release()
cv2.destroyAllWindows()

but when i remove these two lines, code works without any problem. So, why we need these (in python) *