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) *
2.4 doc is obsolete : don't use it. Today it is opencv 4.2 or opencv 3.4.9-dev
and you should destroy videocapture and windows before exiting your program
if you just run
python my.py
you probably don't have to (it's all cleaned up automatically).but try to run it in a repl (and do something else then), or from demo.py, and you'll see, why it's there.