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

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.2k Views
  • 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 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 Offline
        J Offline
        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
        • J JonB
          2 Jan 2018, 20:22

          @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 Offline
          X Offline
          Xenoshell
          wrote on 3 Jan 2018, 08:12 last edited by
          #49

          @JonB I just looked in the folder and i dont have the file vc4_drv_video.so. I just have vc4_dri.so. Also i didnt have vainfo and after installing vainfo and running the command the output was:

          blz@blz-desktop:~$ vainfo
          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
          vaInitialize failed with error code -1 (unknown libva error),exit
          

          I looked at the link you attached and i just dont know what do download. I have a ARM CPU because of my raspberry pi. I have no intel cpu or even a gpu. What can i do to fix that problem?

          J 1 Reply Last reply 3 Jan 2018, 08:24
          0
          • X Xenoshell
            3 Jan 2018, 08:12

            @JonB I just looked in the folder and i dont have the file vc4_drv_video.so. I just have vc4_dri.so. Also i didnt have vainfo and after installing vainfo and running the command the output was:

            blz@blz-desktop:~$ vainfo
            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
            vaInitialize failed with error code -1 (unknown libva error),exit
            

            I looked at the link you attached and i just dont know what do download. I have a ARM CPU because of my raspberry pi. I have no intel cpu or even a gpu. What can i do to fix that problem?

            J Offline
            J Offline
            JonB
            wrote on 3 Jan 2018, 08:24 last edited by
            #50

            @Xenoshell
            Again, I'm afraid I have no answer to your question. I'm only trying to point you in what I think is the right direction. I note there is a "Raspberry Pi" sub-forum here, I don't know if you'd get more help there, or perhaps on the web.

            My point here is: everything you seem to be showing indicates that you have a fundamental problem with your Linux driver situation. Qt in itself does not seem to be relevant. Until you can get through vainfo without it reporting error I presume your camera is not going to work.

            From my very limited understanding, VA-API or similar is to do with video hardware acceleration. If you say you "haven't got a GPU", are you supposed to be in this area at all??

            I'm wondering whether your whole system is misconfigured. Forget Qt. You have a camera, which I think you said had some installation instructions. Go back to that. Goggle for setting up your camera under Linux, or Raspberry Pi. Go the camera's forum, or perhaps a dedicated Raspberry Pi forum on the web. That's the angle you should be approaching this from.

            One thing I've asked you before but don't think you answered: are you able to use that camera at all completely outside of the code you're trying to write in Qt? I assume there must be some generic piece of software that's supposed to work with the camera from, say, System Settings? Like, it should just allow you to enable the camera and perhaps show what it is seeing? I think the Qt angle is like trying to run before you can walk....

            X 1 Reply Last reply 3 Jan 2018, 08:29
            0
            • J JonB
              3 Jan 2018, 08:24

              @Xenoshell
              Again, I'm afraid I have no answer to your question. I'm only trying to point you in what I think is the right direction. I note there is a "Raspberry Pi" sub-forum here, I don't know if you'd get more help there, or perhaps on the web.

              My point here is: everything you seem to be showing indicates that you have a fundamental problem with your Linux driver situation. Qt in itself does not seem to be relevant. Until you can get through vainfo without it reporting error I presume your camera is not going to work.

              From my very limited understanding, VA-API or similar is to do with video hardware acceleration. If you say you "haven't got a GPU", are you supposed to be in this area at all??

              I'm wondering whether your whole system is misconfigured. Forget Qt. You have a camera, which I think you said had some installation instructions. Go back to that. Goggle for setting up your camera under Linux, or Raspberry Pi. Go the camera's forum, or perhaps a dedicated Raspberry Pi forum on the web. That's the angle you should be approaching this from.

              One thing I've asked you before but don't think you answered: are you able to use that camera at all completely outside of the code you're trying to write in Qt? I assume there must be some generic piece of software that's supposed to work with the camera from, say, System Settings? Like, it should just allow you to enable the camera and perhaps show what it is seeing? I think the Qt angle is like trying to run before you can walk....

              X Offline
              X Offline
              Xenoshell
              wrote on 3 Jan 2018, 08:29 last edited by
              #51

              @JonB Yeah i dont expect you to know everything... The camera actually works on a normal camera showing program that was installed with ubuntu mate, so i know the camera is working. I am actually posting on other forums too, the thing is i dont get much info from them either.

              Also one question you didnt answer was if i need the .ui file for all of this to work.

              J 1 Reply Last reply 3 Jan 2018, 08:32
              0
              • X Xenoshell
                3 Jan 2018, 08:29

                @JonB Yeah i dont expect you to know everything... The camera actually works on a normal camera showing program that was installed with ubuntu mate, so i know the camera is working. I am actually posting on other forums too, the thing is i dont get much info from them either.

                Also one question you didnt answer was if i need the .ui file for all of this to work.

                J Offline
                J Offline
                JonB
                wrote on 3 Jan 2018, 08:32 last edited by
                #52

                @Xenoshell

                Also one question you didnt answer was if i need the .ui file for all of this to work.

                That's 'coz I wouldn't have a clue, as I don't use them! But as I say, you can forget Qt till vainfo looks happy.

                The camera actually works on a normal camera showing program that was installed with ubuntu mate

                I don't suppose you can get the source for that program from somewhere.... ?

                X 1 Reply Last reply 3 Jan 2018, 08:52
                0
                • J JonB
                  3 Jan 2018, 08:32

                  @Xenoshell

                  Also one question you didnt answer was if i need the .ui file for all of this to work.

                  That's 'coz I wouldn't have a clue, as I don't use them! But as I say, you can forget Qt till vainfo looks happy.

                  The camera actually works on a normal camera showing program that was installed with ubuntu mate

                  I don't suppose you can get the source for that program from somewhere.... ?

                  X Offline
                  X Offline
                  Xenoshell
                  wrote on 3 Jan 2018, 08:52 last edited by
                  #53

                  @JonB Well its called cheese and a quick google brought me to this github

                  J 2 Replies Last reply 3 Jan 2018, 09:15
                  0
                  • X Xenoshell
                    3 Jan 2018, 08:52

                    @JonB Well its called cheese and a quick google brought me to this github

                    J Offline
                    J Offline
                    JonB
                    wrote on 3 Jan 2018, 09:15 last edited by
                    #54

                    @Xenoshell
                    So I see that says:

                    How to get your camera working:
                    To get your camera working with cheese, you will have to ensure that it works
                    with the Gstreamer Framework and Video4Linux2 (V4L2) or Video4Linux (V4L). To
                    test this, you can use the 'gstreamer-properties' tool.
                    

                    I don't know (again!), but it looks to me as though that interface is not the same thing as vainfo which uses VA API? Have a look at https://en.wikipedia.org/wiki/Video_Acceleration_API ? And that talks about "Software supporting VA API: GStreamer through gstreamer-vaapi[19]" . So maybe you need to get that configured....

                    I'm going to leave this to you, as I know nothing....

                    1 Reply Last reply
                    0
                    • X Xenoshell
                      3 Jan 2018, 08:52

                      @JonB Well its called cheese and a quick google brought me to this github

                      J Offline
                      J Offline
                      JonB
                      wrote on 3 Jan 2018, 20:39 last edited by JonB 1 Mar 2018, 20:41
                      #55

                      @Xenoshell
                      There is literally like one occurrence on the whole of the Interweb of your error in vainfo (va_openDriver() returns -1)!
                      https://bugs.launchpad.net/ubuntu/+source/libva-utils/+bug/1719150
                      It was suggested:

                      Please install mesa-va-drivers and try gain.

                      I suggest you try that.... :)

                      1 Reply Last reply
                      1

                      55/55

                      3 Jan 2018, 20:39

                      • Login

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