Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Code suddenly stops at self.cam = QCamera() , PyQt5.9.2, Qt5.9.3, Python3.5
Forum Updated to NodeBB v4.3 + New Features

Code suddenly stops at self.cam = QCamera() , PyQt5.9.2, Qt5.9.3, Python3.5

Scheduled Pinned Locked Moved Unsolved Language Bindings
pyqtpython
55 Posts 4 Posters 19.8k Views 1 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.
  • X Xenoshell
    12 Dec 2017, 13:05

    @JNBarchan
    I commented QCamera() and obviously i also need to comment the stuff that is in correlation to self.cam because otherwise i would get a simple error because self.cam is not there. Then i also dont get the libpulse error, well tbh there is not much to compile because about half the code is commented.
    I tried using QCamera("/dev/video0) and also video0, this results in the error:

    TypeError: arguments did not match any overloaded call:
      QCamera(QObject parent=None): argument 1 has unexpected type 'str'
      QCamera(QByteArray, QObject parent=None): argument 1 has unexpected type 'str'
      QCamera(QCameraInfo, QObject parent=None): argument 1 has unexpected type 'str'
      QCamera(QCamera.Position, QObject parent=None): argument 1 has unexpected type 'str'
    

    I can follow you that this should be right but how are you supposed to initialize QCamera if you need the QCameraInfo or a QByteArray?
    Are you supposed to initalize without anything -> find out the QByteArray -> initialize QCamera with the correct QByteArray?

    Thanks again for your help

    J Online
    J Online
    JonB
    wrote on 12 Dec 2017, 13:36 last edited by
    #29

    @Xenoshell
    For the way to invoke QCamera(), sorry, I misremembered the constructor, and thought it took a string. It takes a byte array of the name instead. From Python, you'll use str.encode(), e.g. "/dev/video0".encode().

    Maybe it's not a good idea to try to create an "empty" QCamera(). Try using a constructor which does take an actual camera. One of:

    • `QCamera(QCameraInfo.defaultCamera())
    • QCamera("/dev/video0".encode())
    • One of the available cameras returned by the loop:
    for caminfo in QCameraInfo.availableCameras():
        print(caminfo.deviceName())
        acam = QCamera(caminfo)
    

    I hope one of the above works instead of the default constructor. Maybe only root can create the empty one (though have to say I'm dubious)....

    Now that I think I understand what your code is intending to do, I believe you always intended QCamera(QCameraInfo.defaultCamera()). Don't forget the docs admonition:

    QCameraInfo QCameraInfo::defaultCamera()
    Returns the default camera on the system.
    The returned object should be checked using isNull() before being used, in case there is no default camera or no cameras at all.
    See also availableCameras().

    X 1 Reply Last reply 12 Dec 2017, 13:59
    1
    • J JonB
      12 Dec 2017, 13:36

      @Xenoshell
      For the way to invoke QCamera(), sorry, I misremembered the constructor, and thought it took a string. It takes a byte array of the name instead. From Python, you'll use str.encode(), e.g. "/dev/video0".encode().

      Maybe it's not a good idea to try to create an "empty" QCamera(). Try using a constructor which does take an actual camera. One of:

      • `QCamera(QCameraInfo.defaultCamera())
      • QCamera("/dev/video0".encode())
      • One of the available cameras returned by the loop:
      for caminfo in QCameraInfo.availableCameras():
          print(caminfo.deviceName())
          acam = QCamera(caminfo)
      

      I hope one of the above works instead of the default constructor. Maybe only root can create the empty one (though have to say I'm dubious)....

      Now that I think I understand what your code is intending to do, I believe you always intended QCamera(QCameraInfo.defaultCamera()). Don't forget the docs admonition:

      QCameraInfo QCameraInfo::defaultCamera()
      Returns the default camera on the system.
      The returned object should be checked using isNull() before being used, in case there is no default camera or no cameras at all.
      See also availableCameras().

      X Offline
      X Offline
      Xenoshell
      wrote on 12 Dec 2017, 13:59 last edited by Xenoshell 12 Dec 2017, 14:01
      #30

      @JNBarchan
      well that didnt do anything... When i use QCamera("/dev/video0".encode()) or QCamera(QCameraInfo.defaultCamera()) it just prints till 3 and then stops.
      Maybe i need to add myself to the audio group (EDIT: ok already am)

      J 1 Reply Last reply 12 Dec 2017, 14:06
      0
      • X Xenoshell
        12 Dec 2017, 13:59

        @JNBarchan
        well that didnt do anything... When i use QCamera("/dev/video0".encode()) or QCamera(QCameraInfo.defaultCamera()) it just prints till 3 and then stops.
        Maybe i need to add myself to the audio group (EDIT: ok already am)

        J Online
        J Online
        JonB
        wrote on 12 Dec 2017, 14:06 last edited by
        #31

        @Xenoshell
        Then at this point I'm afraid I'm stumped. QCamera(QCameraInfo.defaultCamera()) should definitely not hang. I don't know what is going on in the Qt code which will cause something to do so unless run as root. (I just wonder whether something might be prompting for, say, root password to allow access, and that's why it hangs/goes black....)

        You need one of the experts who knows what the Qt code does to get you anywhere now, I think....

        X 1 Reply Last reply 12 Dec 2017, 14:18
        0
        • J JonB
          12 Dec 2017, 14:06

          @Xenoshell
          Then at this point I'm afraid I'm stumped. QCamera(QCameraInfo.defaultCamera()) should definitely not hang. I don't know what is going on in the Qt code which will cause something to do so unless run as root. (I just wonder whether something might be prompting for, say, root password to allow access, and that's why it hangs/goes black....)

          You need one of the experts who knows what the Qt code does to get you anywhere now, I think....

          X Offline
          X Offline
          Xenoshell
          wrote on 12 Dec 2017, 14:18 last edited by
          #32

          @JNBarchan
          No worries, i think it should work too and am baffled... Maybe i can summon @Lifetime-Qt-Champion @SGaist ? He has also helped me alot in the past. But i am quite sure it has something to do with the gdb output

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Dec 2017, 21:57 last edited by
            #33

            You can't without lots of chocolate...

            Minimal PyQt5 example that shows a viewfinder using the default camera:

            import sys
            
            from PyQt5.QtWidgets import QApplication
            from PyQt5.QtMultimedia import QCamera, QCameraInfo
            from PyQt5.QtMultimediaWidgets import QCameraViewfinder
            
            if __name__ == '__main__':
            
                app = QApplication(sys.argv)
                camera = QCamera(QCameraInfo.defaultCamera());
                viewfinder = QCameraViewfinder()
                viewfinder.show()
                camera.setViewfinder(viewfinder);
                camera.start()
            
                sys.exit(app.exec_())
            

            Does it work for you ?

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

            X J 3 Replies Last reply 13 Dec 2017, 08:01
            1
            • S SGaist
              12 Dec 2017, 21:57

              You can't without lots of chocolate...

              Minimal PyQt5 example that shows a viewfinder using the default camera:

              import sys
              
              from PyQt5.QtWidgets import QApplication
              from PyQt5.QtMultimedia import QCamera, QCameraInfo
              from PyQt5.QtMultimediaWidgets import QCameraViewfinder
              
              if __name__ == '__main__':
              
                  app = QApplication(sys.argv)
                  camera = QCamera(QCameraInfo.defaultCamera());
                  viewfinder = QCameraViewfinder()
                  viewfinder.show()
                  camera.setViewfinder(viewfinder);
                  camera.start()
              
                  sys.exit(app.exec_())
              

              Does it work for you ?

              X Offline
              X Offline
              Xenoshell
              wrote on 13 Dec 2017, 08:01 last edited by Xenoshell
              #34

              @SGaist
              Nope doesnt work. Its the same thing. Without sudo it doesnt do anything and with sudo it just locks up and i have to login again. I cant find a reason why the raspberry pi just locks up. For me thats the strangest thing to happen. I had my code once on Raspbian but now i am on Ubuntu Mate since i always got a segmentation fault on Raspbian.

              J 1 Reply Last reply 14 Dec 2017, 08:55
              0
              • S SGaist
                12 Dec 2017, 21:57

                You can't without lots of chocolate...

                Minimal PyQt5 example that shows a viewfinder using the default camera:

                import sys
                
                from PyQt5.QtWidgets import QApplication
                from PyQt5.QtMultimedia import QCamera, QCameraInfo
                from PyQt5.QtMultimediaWidgets import QCameraViewfinder
                
                if __name__ == '__main__':
                
                    app = QApplication(sys.argv)
                    camera = QCamera(QCameraInfo.defaultCamera());
                    viewfinder = QCameraViewfinder()
                    viewfinder.show()
                    camera.setViewfinder(viewfinder);
                    camera.start()
                
                    sys.exit(app.exec_())
                

                Does it work for you ?

                J Online
                J Online
                JonB
                wrote on 13 Dec 2017, 08:14 last edited by JonB
                #35

                @SGaist
                We have established that for the OP QCamera(QCameraInfo.defaultCamera()) --- or indeed QCamera(anything-at-all-or-nothing) --- hangs unless he runs it via sudo. (The only thing I don't think he has clarified is whether QCamera("nosuchcamera".decode()) succeeds returning an invalid camera object or also hangs --- but I suspect the latter.)

                What would be nice to know from an expert is: from the Qt source code, what does just a minimal QCamera() constructor actually do? It seems to invoke something in the OS/multimedia --- perhaps something which requires a permission --- but what??

                1 Reply Last reply
                0
                • X Xenoshell
                  13 Dec 2017, 08:01

                  @SGaist
                  Nope doesnt work. Its the same thing. Without sudo it doesnt do anything and with sudo it just locks up and i have to login again. I cant find a reason why the raspberry pi just locks up. For me thats the strangest thing to happen. I had my code once on Raspbian but now i am on Ubuntu Mate since i always got a segmentation fault on Raspbian.

                  J Online
                  J Online
                  JonB
                  wrote on 14 Dec 2017, 08:55 last edited by
                  #36

                  @Xenoshell
                  Hmm, have a look at new post which has arrived: https://forum.qt.io/topic/85920/error-running-camera-example/2

                  This confirms your suspicion that libpulse has something to do with cameras and perhaps QCamera. I don't know what to tell you to do about it, but maybe check what you have installed in that light (libpulse & libpulse-dev)?

                  X 1 Reply Last reply 14 Dec 2017, 09:25
                  1
                  • J JonB
                    14 Dec 2017, 08:55

                    @Xenoshell
                    Hmm, have a look at new post which has arrived: https://forum.qt.io/topic/85920/error-running-camera-example/2

                    This confirms your suspicion that libpulse has something to do with cameras and perhaps QCamera. I don't know what to tell you to do about it, but maybe check what you have installed in that light (libpulse & libpulse-dev)?

                    X Offline
                    X Offline
                    Xenoshell
                    wrote on 14 Dec 2017, 09:25 last edited by Xenoshell
                    #37

                    @JNBarchan
                    I knew it! Sadly installing libpulse-dev did nothing for my problem. Everything stays the same.
                    Does that mean that maybe my installation of Qt5 or PyQt5 is faulted? I know that i didnt managed to install PyQt5/Qt5 with the QtMultimedia because somehow the command didnt work and i then just used the repository to get qtmultimedia

                    EDIT: i just checked the groups again and if something strikes my eye. I saw that i am not in the pulse and pulse-access group. I dont think its gonna do anything, though.

                    J 1 Reply Last reply 14 Dec 2017, 10:09
                    0
                    • X Xenoshell
                      14 Dec 2017, 09:25

                      @JNBarchan
                      I knew it! Sadly installing libpulse-dev did nothing for my problem. Everything stays the same.
                      Does that mean that maybe my installation of Qt5 or PyQt5 is faulted? I know that i didnt managed to install PyQt5/Qt5 with the QtMultimedia because somehow the command didnt work and i then just used the repository to get qtmultimedia

                      EDIT: i just checked the groups again and if something strikes my eye. I saw that i am not in the pulse and pulse-access group. I dont think its gonna do anything, though.

                      J Online
                      J Online
                      JonB
                      wrote on 14 Dec 2017, 10:09 last edited by
                      #38

                      @Xenoshell
                      Well it's possible (it would only be your Qt installation, not your PyQt). I don't know how you went about it, as I only fetch from Ubuntu repositories (apt-get) for all things Qt, never from Qt themselves. If you're saying you did a "max-and-match" --- some things one way, some another --- you might not have a consistent/correctly located set of libraries. You might want to clarify what you mean by:

                      i didnt managed to install PyQt5/Qt5 with the QtMultimedia because somehow the command didnt work and i then just used the repository to get qtmultimedia

                      as anything which "didn't work" in this area could be a clue....

                      However, this would be implicated if your code always "hung". But the fact that it does work as root but not as you makes one assume that your installation does work.

                      Deffo think you should post here your problems/try again with anything which "did not work right" during install, especially if it's to do with multimedia....

                      X 1 Reply Last reply 14 Dec 2017, 10:51
                      0
                      • J JonB
                        14 Dec 2017, 10:09

                        @Xenoshell
                        Well it's possible (it would only be your Qt installation, not your PyQt). I don't know how you went about it, as I only fetch from Ubuntu repositories (apt-get) for all things Qt, never from Qt themselves. If you're saying you did a "max-and-match" --- some things one way, some another --- you might not have a consistent/correctly located set of libraries. You might want to clarify what you mean by:

                        i didnt managed to install PyQt5/Qt5 with the QtMultimedia because somehow the command didnt work and i then just used the repository to get qtmultimedia

                        as anything which "didn't work" in this area could be a clue....

                        However, this would be implicated if your code always "hung". But the fact that it does work as root but not as you makes one assume that your installation does work.

                        Deffo think you should post here your problems/try again with anything which "did not work right" during install, especially if it's to do with multimedia....

                        X Offline
                        X Offline
                        Xenoshell
                        wrote on 14 Dec 2017, 10:51 last edited by Xenoshell
                        #39

                        @JNBarchan
                        Well i wanted to install Qt5 from source but in the default installation is not QtMultimedia. So i wanted to use the command to install also QtMultimedia but somehow the command didnt get recognized so i just didnt install QtMulti from source but installed it with a repository. The help command didnt do much for using the correct command, because im quite sure i can read.

                        J 1 Reply Last reply 14 Dec 2017, 11:06
                        0
                        • X Xenoshell
                          14 Dec 2017, 10:51

                          @JNBarchan
                          Well i wanted to install Qt5 from source but in the default installation is not QtMultimedia. So i wanted to use the command to install also QtMultimedia but somehow the command didnt get recognized so i just didnt install QtMulti from source but installed it with a repository. The help command didnt do much for using the correct command, because im quite sure i can read.

                          J Online
                          J Online
                          JonB
                          wrote on 14 Dec 2017, 11:06 last edited by
                          #40

                          @Xenoshell
                          Look, I don't know your situation, but maybe it's possible that your multimedia is "out of sync" with the rest of your Qt installed? Like I said, I'm surprised then that it works for root but not other users, but who knows....

                          Since no-one else seems to be posting to help you on your camera issue, you might want to try a new thread purely about how to correctly install Qt with multimedia under your OS, get it all sorted out properly, and then see if miraculously that solves your problem....

                          X 1 Reply Last reply 14 Dec 2017, 11:54
                          0
                          • J JonB
                            14 Dec 2017, 11:06

                            @Xenoshell
                            Look, I don't know your situation, but maybe it's possible that your multimedia is "out of sync" with the rest of your Qt installed? Like I said, I'm surprised then that it works for root but not other users, but who knows....

                            Since no-one else seems to be posting to help you on your camera issue, you might want to try a new thread purely about how to correctly install Qt with multimedia under your OS, get it all sorted out properly, and then see if miraculously that solves your problem....

                            X Offline
                            X Offline
                            Xenoshell
                            wrote on 14 Dec 2017, 11:54 last edited by
                            #41

                            @JNBarchan
                            Ok i am gonna do that.

                            J 1 Reply Last reply 21 Dec 2017, 09:09
                            0
                            • X Xenoshell
                              14 Dec 2017, 11:54

                              @JNBarchan
                              Ok i am gonna do that.

                              J Online
                              J Online
                              JonB
                              wrote on 21 Dec 2017, 09:09 last edited by
                              #42

                              @Xenoshell

                              Just so you know, I was @JNBarchan but now I have had a change of identity and I am @JonB!

                              @Xenoshell has raised the new installation question to (begin to) sort this out at https://forum.qt.io/topic/85955/reinstall-qt5-with-qtmultimedia-using-ubuntu-mate

                              X 1 Reply Last reply 21 Dec 2017, 10:00
                              0
                              • J JonB
                                21 Dec 2017, 09:09

                                @Xenoshell

                                Just so you know, I was @JNBarchan but now I have had a change of identity and I am @JonB!

                                @Xenoshell has raised the new installation question to (begin to) sort this out at https://forum.qt.io/topic/85955/reinstall-qt5-with-qtmultimedia-using-ubuntu-mate

                                X Offline
                                X Offline
                                Xenoshell
                                wrote on 21 Dec 2017, 10:00 last edited by Xenoshell
                                #43

                                @JonB I just tried my code after the installation and somehow it doesnt stop at qcamera anymore, but now the window that pops out is black and i get a bunch of errors in the terminal.

                                1
                                2
                                3
                                4
                                5
                                Venus USB2.0 Camera: Venus USB2
                                [<PyQt5.QtMultimedia.QCameraInfo object at 0x72ddd3f0>]
                                /dev/video0
                                6
                                
                                (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7\x81\xbb'
                                
                                (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7Ż'
                                
                                (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7	\xbc'
                                
                                (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7M\xbc'
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                7
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                libva info: VA-API version 0.39.0
                                libva info: va_getDriverName() returns 0
                                libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                libva info: va_openDriver() returns -1
                                CameraBin error: "Internal data flow error."
                                CameraBin error: "Internal data flow error."
                                

                                I dont know if now this is because my installation of qt5 is faulted or something else. Do i have to reinstall PyQt5 too?
                                @SGaist here is my code again.

                                import sys
                                from PyQt5 import QtCore , QtWidgets, QtGui, QtMultimedia, QtMultimediaWidgets
                                from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot
                                from PyQt5.QtWidgets import QApplication, QPushButton, QMainWindow
                                from PyQt5.QtMultimedia import QCamera, QCameraInfo, QMediaObject, QCameraViewfinderSettings, QCameraImageCapture
                                from PyQt5.QtMultimediaWidgets import QCameraViewfinder
                                
                                
                                class Camera(QObject):
                                    def __init__(self, parent = QObject()):
                                        super(Camera, self).__init__(parent)
                                        print("3")
                                        self.cam = QCamera("/dev/video0".encode())   #QCameraInfo.defaultCamera()
                                        print("4")
                                        self.caminfo = QCameraInfo(self.cam)
                                        self.camvfind = QCameraViewfinder()
                                        self.camvfindset = QCameraViewfinderSettings()
                                        self.cammode = self.cam.CaptureMode(0)
                                        self.camimgcap = QCameraImageCapture(self.cam)
                                
                                    def iniCamera(self):
                                        print(self.caminfo.description())
                                        print(self.caminfo.availableCameras())
                                        
                                        for caminfo in QCameraInfo.availableCameras():
                                            print(caminfo.deviceName())
                                        
                                        if self.cam.isCaptureModeSupported(self.cammode):
                                            print("Capturemode supported")
                                    
                                    def startVid(self):
                                        #self.camimgcap.CaptureDestination(2)
                                        
                                        self.camvfind.show()
                                        
                                        self.cam.setViewfinder(self.camvfind)
                                        
                                        self.cam.setCaptureMode(self.cammode)
                                        
                                        self.cam.start()
                                        
                                        
                                
                                if __name__ == '__main__':
                                    print("1")
                                    app = QtWidgets.QApplication(sys.argv)
                                    print("2")
                                    cam = Camera()
                                    print("5")
                                    cam.iniCamera()
                                    print("6")
                                    cam.startVid()
                                    print("7")
                                    sys.exit(app.exec_())
                                
                                J 1 Reply Last reply 21 Dec 2017, 10:09
                                0
                                • X Xenoshell
                                  21 Dec 2017, 10:00

                                  @JonB I just tried my code after the installation and somehow it doesnt stop at qcamera anymore, but now the window that pops out is black and i get a bunch of errors in the terminal.

                                  1
                                  2
                                  3
                                  4
                                  5
                                  Venus USB2.0 Camera: Venus USB2
                                  [<PyQt5.QtMultimedia.QCameraInfo object at 0x72ddd3f0>]
                                  /dev/video0
                                  6
                                  
                                  (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7\x81\xbb'
                                  
                                  (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7Ż'
                                  
                                  (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7	\xbc'
                                  
                                  (python3:2758): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7M\xbc'
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  7
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  libva info: VA-API version 0.39.0
                                  libva info: va_getDriverName() returns 0
                                  libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                  libva info: va_openDriver() returns -1
                                  CameraBin error: "Internal data flow error."
                                  CameraBin error: "Internal data flow error."
                                  

                                  I dont know if now this is because my installation of qt5 is faulted or something else. Do i have to reinstall PyQt5 too?
                                  @SGaist here is my code again.

                                  import sys
                                  from PyQt5 import QtCore , QtWidgets, QtGui, QtMultimedia, QtMultimediaWidgets
                                  from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot
                                  from PyQt5.QtWidgets import QApplication, QPushButton, QMainWindow
                                  from PyQt5.QtMultimedia import QCamera, QCameraInfo, QMediaObject, QCameraViewfinderSettings, QCameraImageCapture
                                  from PyQt5.QtMultimediaWidgets import QCameraViewfinder
                                  
                                  
                                  class Camera(QObject):
                                      def __init__(self, parent = QObject()):
                                          super(Camera, self).__init__(parent)
                                          print("3")
                                          self.cam = QCamera("/dev/video0".encode())   #QCameraInfo.defaultCamera()
                                          print("4")
                                          self.caminfo = QCameraInfo(self.cam)
                                          self.camvfind = QCameraViewfinder()
                                          self.camvfindset = QCameraViewfinderSettings()
                                          self.cammode = self.cam.CaptureMode(0)
                                          self.camimgcap = QCameraImageCapture(self.cam)
                                  
                                      def iniCamera(self):
                                          print(self.caminfo.description())
                                          print(self.caminfo.availableCameras())
                                          
                                          for caminfo in QCameraInfo.availableCameras():
                                              print(caminfo.deviceName())
                                          
                                          if self.cam.isCaptureModeSupported(self.cammode):
                                              print("Capturemode supported")
                                      
                                      def startVid(self):
                                          #self.camimgcap.CaptureDestination(2)
                                          
                                          self.camvfind.show()
                                          
                                          self.cam.setViewfinder(self.camvfind)
                                          
                                          self.cam.setCaptureMode(self.cammode)
                                          
                                          self.cam.start()
                                          
                                          
                                  
                                  if __name__ == '__main__':
                                      print("1")
                                      app = QtWidgets.QApplication(sys.argv)
                                      print("2")
                                      cam = Camera()
                                      print("5")
                                      cam.iniCamera()
                                      print("6")
                                      cam.startVid()
                                      print("7")
                                      sys.exit(app.exec_())
                                  
                                  J Online
                                  J Online
                                  JonB
                                  wrote on 21 Dec 2017, 10:09 last edited by JonB
                                  #44

                                  @Xenoshell
                                  Well I think that's actually progress!!

                                  Experts will know better than I, but obviously it looks like there are issues which need fixing, which hopefully will then mean you can use the camera OK!

                                  You do not have to do any PyQt re-installs. However, you should ensure that the version of PyQt matches whatever version you have now for Qt. And don't blame me if they don't match, I have a nasty feeling I might have read somewhere that PyQt only goes up to Qt 5.9 at present till the new year. If your Qt is 5.10 we'll have to hope that PyQt 5.9 works sufficiently with it --- you'd have to Google.

                                  But before you look at PyQt, wait for an expert here to explain what your error messages indicate.

                                  P.S.
                                  You say it used to work when run as sudo. Is that still the case now, or same behaviour regardless?

                                  X 1 Reply Last reply 21 Dec 2017, 11:47
                                  1
                                  • J JonB
                                    21 Dec 2017, 10:09

                                    @Xenoshell
                                    Well I think that's actually progress!!

                                    Experts will know better than I, but obviously it looks like there are issues which need fixing, which hopefully will then mean you can use the camera OK!

                                    You do not have to do any PyQt re-installs. However, you should ensure that the version of PyQt matches whatever version you have now for Qt. And don't blame me if they don't match, I have a nasty feeling I might have read somewhere that PyQt only goes up to Qt 5.9 at present till the new year. If your Qt is 5.10 we'll have to hope that PyQt 5.9 works sufficiently with it --- you'd have to Google.

                                    But before you look at PyQt, wait for an expert here to explain what your error messages indicate.

                                    P.S.
                                    You say it used to work when run as sudo. Is that still the case now, or same behaviour regardless?

                                    X Offline
                                    X Offline
                                    Xenoshell
                                    wrote on 21 Dec 2017, 11:47 last edited by
                                    #45

                                    @JonB i just tested it and sudo doesnt make a difference anymore. I guess thats a good thing. But yeah i dont see a camera feed

                                    1 Reply Last reply
                                    0
                                    • S SGaist
                                      12 Dec 2017, 21:57

                                      You can't without lots of chocolate...

                                      Minimal PyQt5 example that shows a viewfinder using the default camera:

                                      import sys
                                      
                                      from PyQt5.QtWidgets import QApplication
                                      from PyQt5.QtMultimedia import QCamera, QCameraInfo
                                      from PyQt5.QtMultimediaWidgets import QCameraViewfinder
                                      
                                      if __name__ == '__main__':
                                      
                                          app = QApplication(sys.argv)
                                          camera = QCamera(QCameraInfo.defaultCamera());
                                          viewfinder = QCameraViewfinder()
                                          viewfinder.show()
                                          camera.setViewfinder(viewfinder);
                                          camera.start()
                                      
                                          sys.exit(app.exec_())
                                      

                                      Does it work for you ?

                                      X Offline
                                      X Offline
                                      Xenoshell
                                      wrote on 2 Jan 2018, 08:46 last edited by
                                      #46

                                      @SGaist @JonB, hello i wish you a happy new year. I am gonna be now more active. SGaist, can you please interpret the newest output i recieved? My screen doesnt lock up anymore and all but i still have a black screen?

                                      Maybe thats a dumb question but do i need a .ui file for all of this to work? Currently i have besides the qt5.py file no other related to all this? I figured that i can add all of the GUI stuff after the code actually works. Am i wrong with that assumption?

                                      Greets

                                      Xeno

                                      1 Reply Last reply
                                      0
                                      • X Offline
                                        X Offline
                                        Xenoshell
                                        wrote on 2 Jan 2018, 12:26 last edited by Xenoshell 1 Feb 2018, 12:28
                                        #47

                                        I activated OpenGL for the Raspberry Pi and now the error changed a little bit. It produces actually more errors.
                                        I googled for the vc4_drv_video.so and it solution was to just activate OpenGL which did nothing.

                                        blz@blz-desktop:~/Schreibtisch$ python3 qt5.py
                                        1
                                        2
                                        3
                                        
                                        (gst-plugin-scanner:1628): GLib-GObject-WARNING **: cannot register existing type 'ClutterGstVideoSink'
                                        
                                        (gst-plugin-scanner:1628): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
                                        
                                        (gst-plugin-scanner:1628): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
                                        
                                        (gst-plugin-scanner:1628): GStreamer-CRITICAL **: gst_element_register: assertion 'g_type_is_a (type, GST_TYPE_ELEMENT)' failed
                                        4
                                        5
                                        Venus USB2.0 Camera: Venus USB2
                                        [<PyQt5.QtMultimedia.QCameraInfo object at 0x72e273f0>]
                                        /dev/video0
                                        6
                                        
                                        (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7\x81\xbb'
                                        
                                        (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7Ż'
                                        
                                        (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7	\xbc'
                                        
                                        (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7M\xbc'
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        7
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        libva info: VA-API version 0.39.0
                                        libva info: va_getDriverName() returns 0
                                        libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                        libva info: va_openDriver() returns -1
                                        CameraBin error: "Internal data flow error."
                                        CameraBin error: "Internal data flow error."
                                        
                                        J 1 Reply Last reply 2 Jan 2018, 20:22
                                        0
                                        • X Xenoshell
                                          2 Jan 2018, 12:26

                                          I activated OpenGL for the Raspberry Pi and now the error changed a little bit. It produces actually more errors.
                                          I googled for the vc4_drv_video.so and it solution was to just activate OpenGL which did nothing.

                                          blz@blz-desktop:~/Schreibtisch$ python3 qt5.py
                                          1
                                          2
                                          3
                                          
                                          (gst-plugin-scanner:1628): GLib-GObject-WARNING **: cannot register existing type 'ClutterGstVideoSink'
                                          
                                          (gst-plugin-scanner:1628): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
                                          
                                          (gst-plugin-scanner:1628): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
                                          
                                          (gst-plugin-scanner:1628): GStreamer-CRITICAL **: gst_element_register: assertion 'g_type_is_a (type, GST_TYPE_ELEMENT)' failed
                                          4
                                          5
                                          Venus USB2.0 Camera: Venus USB2
                                          [<PyQt5.QtMultimedia.QCameraInfo object at 0x72e273f0>]
                                          /dev/video0
                                          6
                                          
                                          (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7\x81\xbb'
                                          
                                          (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7Ż'
                                          
                                          (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7	\xbc'
                                          
                                          (python3:1626): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstVaapiSink' has no property named '0\xff\xf7M\xbc'
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          7
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          libva info: VA-API version 0.39.0
                                          libva info: va_getDriverName() returns 0
                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          CameraBin error: "Internal data flow error."
                                          CameraBin error: "Internal data flow error."
                                          
                                          J Online
                                          J Online
                                          JonB
                                          wrote on 2 Jan 2018, 20:22 last edited by JonB 1 Feb 2018, 20:40
                                          #48

                                          @Xenoshell

                                          libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so
                                          libva info: va_openDriver() returns -1
                                          

                                          I assume this is the root of your problems. So does file /usr/lib/arm-linux-gnueabihf/dri/vc4_drv_video.so even exist?

                                          Also, nothing to do with Qt, you're supposed to be able to run command vainfo: https://wiki.archlinux.org/index.php/Hardware_video_acceleration

                                          X 1 Reply Last reply 3 Jan 2018, 08:12
                                          0

                                          • Login

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