title: cv2.VideoCapture(0, cv2.DSHOW) returns none
body: <p>I'm trying to capture video from an in-build webcam on a laptop (or external USB camera) using opencv, specifically VideoCapture with the DSHOW argument.
  I know there is a way to set the resolution and even FPS, however the DirectShow argument for the API returns <strong>none</strong> when I included it in the code.</p>
  <p>For example;</p>
  <pre><code># returns my webcam's stream, but all optional arguments are ignored
  camera = cv2.VideoCapture(0)
  camera = cv2.VideoCapture(0, cv2.CAP_V4L2)
  
  # returns none and loops infinitely or errors out when *if im.any()*
  camera = cv2.VideoCapture(0, cv2.CAP_DSHOW)
  </code></pre>
  <p>This is the code that follows after the above;</p>
  <pre><code># should set resolution, settings are always ignored
  camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
  camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
  
  while(True):
      retval, im = camera.read()
      if im.any(): # errors out when image is none
          cv2.imshow(&quot;image&quot;, im)
  
      k = cv2.waitKey(33)
      if k==27: # Esc key press
          print('Resolution: {0}x and {1}y'.format(im.shape[1],im.shape[0]))
          print('FPS: {0}'.format(camera.get(cv2.CAP_PROP_FPS)))
          break
  
  camera.release()
  cv2.destroyAllWindows()
  </code></pre>
  <p>Is the DSHOW the correct API to use and is it the only API to use that can change resolution and FPS of a camera stream using opencv? Or is there something else I'm doing incorrectly?</p>
  <p>More details about the system.</p>
  <ul>
  <li>Ubuntu 18.04.6</li>
  <li>python 3.9.5</li>
  <li>opencv-python 4.5.2.52</li>
  </ul>
  <p>Thank you in advance for the help!</p>
  <p>Regards, Tiz</p>