What is the use of function destroyAllWindows() if the window automatically gets destroyed using waitKey() function?

Pranjal sharma picture Pranjal sharma · Jun 4, 2018 · Viewed 8.1k times · Source
#!/usr/bin/python3    
import cv2     
cam=cv2.VideoCapture(0)

checking if camera is working!!

cam.isOpened():
    print("Working")

while(cam.isOpened()):
    status,frame=cam.read()
    cv2.imshow('camera1',frame)
    if cv2.waitKey(1) & 0xFF==ord('q') :
            break

Removing windows by calling below function
If i dont write this function then also it will run properly!!

   cv2.destroyAllWindows()
   cam.release()

Answer