title: OpenCV webcam image broken
body: <p>I wrote a script in Python3 and OpenCV 3.1 for timelapse photos on Odroid C1:</p>
  
  <p>Unfortunately sometimes images from the webcam are messed up:
  Here's are some example photographs.</p>
  
  <p><a href="https://i.stack.imgur.com/pOOBu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pOOBu.jpg" alt="enter image description here"></a> 
  <a href="https://i.stack.imgur.com/NJ1Pl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NJ1Pl.jpg" alt="enter image description here"></a></p>
  
  <p>And here's the source code:</p>
  
  <pre><code>import numpy as np
  import cv2
  import time
  import datetime
  import sys
  
  cap = cv2.VideoCapture(0) # USB webcam
  
  cap.set(3,2304.0) #  Resolution: Width
  cap.set(4,1296.0) # Resolution: Height
  cap.set(5, 6) #webcam capture FPS 
  print(str(cap.get(3)),str(cap.get(4)),str(cap.get(5)))
  
  
  def captureImage():
           ret, frame = cap.read()
           curr_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
           filename = 'littleGarden_'+curr_time +'.jpg'
           file_to_save = folder_to_save + filename
           cv2.imwrite(file_to_save,frame)
           print("File saved ", file_to_save)
  
  
  ret, frame = cap.read()
  while(True):
      # Capture frame-by-frame
      if cv2.waitKey(1) &amp; 0xFF == ord('q'):
          break
      captureImage()
      time.sleep(delay)
  
  # When everything done, release the capture
  cap.release()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>For reference, the first argument in the cap.set() command refers to the enumeration of the camera properties, listed below:</p>
  
  <pre><code>0. CV_CAP_PROP_POS_MSEC Current position of the video file in milliseconds.
  1. CV_CAP_PROP_POS_FRAMES 0-based index of the frame to be decoded/captured next.
  2. CV_CAP_PROP_POS_AVI_RATIO Relative position of the video file
  3. CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
  4. CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.
  5. CV_CAP_PROP_FPS Frame rate.
  </code></pre>
  
  <p>Is there any way to fix it?</p>