I had a problem like you, in my case i closed the cammera with cap.release() immediately after capturing frames
cap.release()