Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97911

QVideoWidget stopped working as QCamera viewfinder after Qt upgrade 6.2.0->6.2.1

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.3.0 Alpha, 6.2
    • 6.2.1
    • Multimedia
    • None
    • Linux/X11
    • ed857e84f3c0ab90ac6dfff1aecce460f56e1a9a (qt/qtmultimedia/dev) b4b6942a5a7dc4313dafd6a0d1f70d70ce8dfb16 (qt/qtmultimedia/6.2)

    Description

      QVideoWidget is used as a viewfinder for QCamera with help of QImageCapture.setVideoOutput(). It works with Qt 6.2.0 and shows live image from camera but doesn't work (it is black) with Qt 6.2.1.

      Below is python code to reproduce the problem - it works with 6.2.0 and doesn't work with 6.2.1 (commented part was added to store captured image - it works with 6.2.1 and image is stored on disk. The problem is only with viewfinder).

      The same problem was reported here for official camera example

       

      from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QPushButton
      from PySide6.QtMultimedia import QCamera, QMediaCaptureSession, QImageCapture
      from PySide6.QtMultimediaWidgets import QVideoWidget
      from PySide6.QtGui import QImage
      
      class CameraWnd(QMainWindow):
          def __init__(self):
              QMainWindow.__init__(self)
              self.layout = QVBoxLayout()        
              self.viewfinder = QVideoWidget(self)
              self.layout.addWidget(self.viewfinder)
              self.viewfinder.setMinimumSize(720, 405)        
              self.button = QPushButton(self)
              self.button.setText("Capture")
              self.layout.addWidget(self.button)        
              self.wnd = QWidget(self)
              self.wnd.setLayout(self.layout)
              self.setCentralWidget(self.wnd)        
              self.camera = QCamera()
              self.captureSession = QMediaCaptureSession()
              self.img_capture = QImageCapture(self.camera)
              self.captureSession.setCamera(self.camera)
              self.captureSession.setVideoOutput(self.viewfinder)
              self.captureSession.setImageCapture(self.img_capture)
              self.button.clicked.connect(self.on_button)
              self.img_capture.errorOccurred.connect(self.on_error)
              self.camera.errorOccurred.connect(self.on_cam_error)
              # self.img_capture.imageCaptured.connect(self.captured)
              self.camera.start()    
          
          def on_button(self):
              if self.img_capture.isReadyForCapture():
                  print("READY")
                  # self.img_capture.capture()
              else:
                  print("NOT READY")    
      
          def on_error(self, _id, _error, error_str):
              print(f"Error: {error_str}")    
      
          def on_cam_error(self, _error, error_str):
              print(f"Error: {error_str}")    
      
          # def captured(self, id: int, img: QImage):
          #     print(id)
          #     img.save('/home/user/test.png')
      
      def main():
          app = QApplication()    
          camera = CameraWnd()
          camera.show()    
          return app.exec()
      
      if __name__ == '__main__':
          main()
      

       

      Attachments

        1. QTBUG_97911.cpp
          0.5 kB
        2. QTBUG_97911.qml
          0.3 kB
        For Gerrit Dashboard: QTBUG-97911
        # Subject Branch Project Status CR V

        Activity

          People

            laknoll Lars Knoll
            starterkit Ivan Ivanov
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes