Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QVideoWidget stopped working as viewfinder after Qt upgrade 6.2.0->6.2.1 - bug?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved Qt for Python
8 Posts 3 Posters 813 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StarterKit
    wrote on last edited by StarterKit
    #1

    Hi all,
    I have a code that uses QVideoWidget as a viewfinder for QCamera. Code snipped is below, here are my comments:

    • I use Linux for my tests;
    • this code works ok with PySide6 6.2.0 - I see live image in viewfinder;
    • with PySide6 6.2.1 the viewfinder is black;
    • there are commented pieces of code - I added this to check 6.2.1 more and image is successfully saved if I press the button (i.e. QImageCapture itself works);
    • no errors are printed by this code;

    Does it mean I missed some change between 6.2.0 and 6.2.1? Or something is broken?

    Code:

    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("Check state")
            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()
    
    
    eyllanescE 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since your code is pretty simple and does look correct, It looks like a regression.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Since your code is pretty simple and does look correct, It looks like a regression.

        S Offline
        S Offline
        StarterKit
        wrote on last edited by
        #3

        @SGaist, thanks. So, I'll go and report a bug

        eyllanescE 1 Reply Last reply
        0
        • S StarterKit

          Hi all,
          I have a code that uses QVideoWidget as a viewfinder for QCamera. Code snipped is below, here are my comments:

          • I use Linux for my tests;
          • this code works ok with PySide6 6.2.0 - I see live image in viewfinder;
          • with PySide6 6.2.1 the viewfinder is black;
          • there are commented pieces of code - I added this to check 6.2.1 more and image is successfully saved if I press the button (i.e. QImageCapture itself works);
          • no errors are printed by this code;

          Does it mean I missed some change between 6.2.0 and 6.2.1? Or something is broken?

          Code:

          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("Check state")
                  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()
          
          
          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #4

          @StarterKit I have compiled the official example https://doc.qt.io/qt-6/qtmultimedia-multimediawidgets-camera-example.html and I reproduce the error so it is clearly a bug.

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          0
          • S StarterKit

            @SGaist, thanks. So, I'll go and report a bug

            eyllanescE Offline
            eyllanescE Offline
            eyllanesc
            wrote on last edited by
            #5

            @StarterKit You must report it as a QtMultimedia bug, not PySide6

            If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

            S 1 Reply Last reply
            1
            • eyllanescE eyllanesc

              @StarterKit You must report it as a QtMultimedia bug, not PySide6

              S Offline
              S Offline
              StarterKit
              wrote on last edited by
              #6

              @eyllanesc have you tried it on Linux also? or another OS?

              eyllanescE 1 Reply Last reply
              0
              • S StarterKit

                @eyllanesc have you tried it on Linux also? or another OS?

                eyllanescE Offline
                eyllanescE Offline
                eyllanesc
                wrote on last edited by
                #7

                @StarterKit On Linux, with Qt 6.2.0 it worked great but no longer on Qt 6.2.1

                If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  StarterKit
                  wrote on last edited by
                  #8

                  https://bugreports.qt.io/browse/QTBUG-97911

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved