title: Using Raspberry Pi + Webcam to record video in python, but sometimes camera does not turn on/off as I expected
body: <p>I am trying to using Raspberry Pi + webcam (logitech) to record video, but there is a problem at the first step... I would like to male the webcam turned on when needed, and turned off otherwise, however when I try</p>
  
  <pre><code>cap = cv2.VideoCapture(0)
  if cap.isOpened() != True:
      cap.open(0)
  </code></pre>
  
  <p>the webcam still didn't turn on sometimes...
  so I would like to know if someone knows the solution, I will appreciate you!
  Thanks! </p>