title: How to click a photo using QCamera in PyQt5?
body: <p>PyQT5 QCamera not clicking a photo</p>
  <hr />
  <p>I tried refering their official PyQt5 QCamera Documentation but didn't understood much.</p>
  <ol>
  <li>I have created a Mainwindow with a pushbutton</li>
  <li>Button on click, executes the clickphoto function</li>
  <li>clickphoto function runs to capture image only when available cameras list length &gt; 0,  else prints Error</li>
  </ol>
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  from PyQt5.QtWidgets import *
  from PyQt5.QtMultimedia import *
  from PyQt5.QtMultimediaWidgets import *
  import os
  class Ui_MainWindow(object):
      def clickphoto(self):
          print(&quot;clickphoto Called !&quot;)
          available_cameras = QCameraInfo.availableCameras()
          if len(available_cameras)&gt;0:
              print(available_cameras[0].description())
              try:
                  camera = QCamera(available_cameras[0])
                  camera.setCaptureMode(QCamera.CaptureStillImage)
                  camera.start()
                  capture = QCameraImageCapture(camera)
                  capture.capture(str(os.getcwd())+&quot;//&quot;+&quot;999.jpg&quot;)
  
                  # i also tried capture.capture(&quot;999.jpg&quot;) still no output 
                  # (checked in Pictures folder)
  
              except Exception as e:
                  print(&quot;Exception occured, &quot;,e)
          else:
              print(&quot;Error&quot;)
  
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(&quot;MainWindow&quot;)
          MainWindow.resize(251, 271)
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName(&quot;centralwidget&quot;)
          self.clickphotobtn = QtWidgets.QPushButton(self.centralwidget)
          self.clickphotobtn.setGeometry(QtCore.QRect(90, 110, 75, 23))
          self.clickphotobtn.setObjectName(&quot;clickphotobtn&quot;)
  
          # click event !!
          self.clickphotobtn.clicked.connect(self.clickphoto)
  
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 251, 23))
          self.menubar.setObjectName(&quot;menubar&quot;)
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName(&quot;statusbar&quot;)
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate(&quot;MainWindow&quot;, &quot;MainWindow&quot;))
          self.clickphotobtn.setText(_translate(&quot;MainWindow&quot;, &quot;Capture&quot;))
  
  
  if __name__ == &quot;__main__&quot;:
      import sys
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>
  <p>Output</p>
  <pre><code>PS C:\Users\Beast80K\Documents\Auto Brightness&gt; &amp; C:/Users/Beast80K/AppData/Local/Programs/Python/Python39/python.exe &quot;c:/Users/Beast80K/Documents/Auto Brightness/trycappic.py&quot;
  clickphoto Called !
  USB2.0 PC CAMERA
  Unsupported media type: &quot;{32595559-0000-0010-8000-00AA00389B71}&quot;
  Unsupported media type: &quot;{32595559-0000-0010-8000-00AA00389B71}&quot;
  Unsupported media type: &quot;{32595559-0000-0010-8000-00AA00389B71}&quot;
  Unsupported media type: &quot;{32595559-0000-0010-8000-00AA00389B71}&quot;
  Unsupported media type: &quot;{32595559-0000-0010-8000-00AA00389B71}&quot;
  </code></pre>
  <ul>
  <li>Python 3.9.6</li>
  <li>Qt version: 5.15.2</li>
  <li>Windows 10 21h1 (OS Build 19043.1237)</li>
  </ul>