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


  • Moderators

    @Xenoshell Please take a look at https://www.tutorialspoint.com/unix/unix-file-permission.htm
    Each device is represented by a device file which. To read from such a device you read from the device file to write to the device you write into this file. UNIX/Linux access rights apply to device files as well. So, you have user, user groups and others. You have read/write and execute rights. My guess is that the user you are using on your machine does not have access rights to the camera device file. Usually to solve this you just need to add this user to the correct user group (probably this group is called "video"). To see in which groups your user is member execute the command "groups" in a terminal. To add a user to a group see https://askubuntu.com/questions/79565/how-to-add-existing-user-to-an-existing-group



  • @JNBarchan

    1. input: cat /etc/group -> output (i am in the group video)
      I just post this if i dont see a group i should be in:
    root:x:0:
    daemon:x:1:
    bin:x:2:
    sys:x:3:
    adm:x:4:syslog,blz
    tty:x:5:
    disk:x:6:
    lp:x:7:
    mail:x:8:
    news:x:9:
    uucp:x:10:
    man:x:12:
    proxy:x:13:
    kmem:x:15:
    dialout:x:20:
    fax:x:21:
    voice:x:22:
    cdrom:x:24:blz
    floppy:x:25:
    tape:x:26:
    sudo:x:27:blz
    audio:x:29:pulse,blz
    dip:x:30:blz
    www-data:x:33:
    backup:x:34:
    operator:x:37:
    list:x:38:
    irc:x:39:
    src:x:40:
    gnats:x:41:
    shadow:x:42:
    utmp:x:43:
    video:x:44:blz
    sasl:x:45:
    plugdev:x:46:blz
    staff:x:50:
    games:x:60:
    users:x:100:
    nogroup:x:65534:
    systemd-journal:x:101:
    systemd-timesync:x:102:
    systemd-network:x:103:
    systemd-resolve:x:104:
    systemd-bus-proxy:x:105:
    input:x:106:blz
    crontab:x:107:
    syslog:x:108:
    netdev:x:109:
    messagebus:x:110:
    uuidd:x:111:
    mlocate:x:112:
    ssh:x:113:
    ssl-cert:x:114:
    lpadmin:x:115:blz
    lightdm:x:116:
    nopasswdlogin:x:117:
    ntp:x:118:
    avahi-autoipd:x:119:
    avahi:x:120:
    bluetooth:x:121:
    scanner:x:122:saned
    colord:x:123:
    pulse:x:124:
    pulse-access:x:125:
    rtkit:x:126:
    saned:x:127:
    whoopsie:x:128:
    gpio:x:999:blz
    i2c:x:998:blz
    spi:x:997:blz
    blz:x:1000:
    sambashare:x:129:blz
    
    
    QCamera(0x72dbe3b0)
    

    From the QCamera documentation: "QCamera::QCamera(const QByteArray &deviceName, QObject *parent = Q_NULLPTR) Construct a QCamera from deviceName and parent."
    Correct me if i'm wrong but that means if i know the deviceName that i can just initialize the Camera with QCamera(0x72dbe3b0).

    gdb is a debug program which can be used for segmentation fault errors.

    @jsulm

    Input:

    ls -l /home/blz/Schreibtisch/qt5.py
    

    Output:
    -rwxrwxrwx 1 blz blz 1537 Dez 7 10:33 /home/blz/Schreibtisch/qt5.py
    I guess that means that i have full accessibility to qt5.py

    Thanks for your help. I appreciate your feedback.

    Greets


  • Moderators

    @Xenoshell 1. Well, the question is: what is the group of the camera device file?

    1. You can use this code to see all the camera device names (http://doc.qt.io/qt-5/qcamera.html):
    QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
    foreach (const QCameraInfo &cameraInfo, cameras) {
        qDebug() << cameraInfo.deviceName();
    }
    
    1. Yes, you can use GDB to get more information if your app crashes
    2. Everyone has full access to Schreibtisch/qt5.py. Not sure how is this related?


  • @Xenoshell

    Nothing looks interesting in your groups. Never mind, it was only an idea of @jsulm's, maybe or maybe not relevant.

    Correct me if i'm wrong but that means if i know the deviceName that i can just initialize the Camera with QCamera(0x72dbe3b0).

    It's so wrong. Fortunately in C++ it won't compile, in Python I hope it will spit it back at you. You really need to understand why this is plain wrong in any language/circumstance, if you're new to programming. You must pass a string which has the value of a device name to QCamera(), e.g. QCamera("camera-device-name"), or a device name picked up from a QCameraInfo.deviceName() (which itself is a string).

    Please try @jsulm's suggestion of enumerating the available cameras you have. In Python it'll be like:

    for cameraInfo in QCameraInfo.availableCameras():
        print(cameraInfo.deviceName())
    

    QString QCameraInfo::deviceName() const
    Returns the device name of the camera
    This is a unique ID to identify the camera and may not be human-readable.

    So a device name might come out like abc1234 (I don't know 'coz I haven't got one to test). Then the actual Linux device will be /dev/abc1234, or something like that. We want you to ls -l that, and look at its owner & group permissions, and see if you have access to it under your own user, not sudo. This is what we mean about "permissions", not the permissions you list for /home/blz/Schreibtisch/qt5.py.



  • @JNBarchan, @jsulm
    The output for the for-loop is:

    /dev/video0
    

    Here the output is:

    blz@blz-desktop:~$ ls -l /dev/video0
    crw-rw----+ 1 root video 81, 0 Dez 11 10:55 /dev/video0
    
    

    To me it looks like i dont have the permission to everything.


  • Moderators

    @Xenoshell Add yourself to the video group if it's not already the case



  • @Xenoshell
    You can see if you're already a member of video group via executing command groups.

    If your username is blz, I think you already are....

    If you are a member, it would then look like: as yourself, not root, you do have access to the camera device, hence you say it seems to "initially open", but then something else is happening which works as root but not as you.... You could temporarily sudo chmod 666 /dev/video0, see if that helps, then revert to sudo chmod 660 /dev/video0.



  • @jsulm @JNBarchan ,
    i am already member of the video group.
    The camera device only opens if i use sudo. If i dont it just gets stuck at self.cam = QCamera().
    After the command sudo chmod 666 /dev/video0 i tried using qt5.py without sudo but it just got stuck.
    So there has to be a group which i am not a member of that uses QCamera(). Am i at least right with this assumption?



  • Ok i cant reproduce the gdb output anymore. It just stops at 1 and then somehow locks up and i have to relog again.
    I somehow have this feeling that the code/the usb-camera use audio or at least try to use it. When i want to turn off the pi i always get the message that "Pulse Audio Sound System" is currently running and if i want to terminate it.
    Tomorrow i will sit down and try to get the gdb output without sudo /with sudo and look what is possible.
    Debugging can really be stressful...



  • @jsulm, @JNBarchan
    Here i am again, this is the new gdb output:

    (gdb) run qt5.py
    Starting program: /usr/bin/python3 qt5.py
    Cannot parse expression `.L1185 4@r4'.
    warning: Probes-based dynamic linker interface failed.
    Reverting to original interface.
    
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
    1
    [New Thread 0x72b39470 (LWP 4134)]
    2
    3
    [New Thread 0x6de10470 (LWP 4139)]
    [Thread 0x6de10470 (LWP 4139) exited]
    [New Thread 0x6de10470 (LWP 4140)]
    [Thread 0x6de10470 (LWP 4140) exited]
    

    At this output is libpulse.so and also libasound.so.2 i talked about in my post above. It could actually be that QCamera() tries to also initalise Audio but obviously i dont have any audiooutput plugged in and thats why it stops at QCamera

    (gdb) bt
    #0  __libc_do_syscall () at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
    #1  0x76f21c0a in __GI_ppoll (fds=0x7001a8, nfds=1, timeout=<optimized out>, 
        sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:50
    #2  0x73389e12 in pa_mainloop_poll ()
       from /usr/lib/arm-linux-gnueabihf/libpulse.so.0
    #3  0x7338a290 in pa_mainloop_iterate ()
       from /usr/lib/arm-linux-gnueabihf/libpulse.so.0
    #4  0x6de2888c in conf_pulse_hook_load_if_running ()
       from /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_conf_pulse.so
    #5  0x6e01c9f2 in ?? () from /usr/lib/arm-linux-gnueabihf/libasound.so.2
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)
    

    Here the info threads:

    (gdb) info threads
      Id   Target Id         Frame 
    * 1    Thread 0x76ff6300 (LWP 4204) "python3" __libc_do_syscall ()
        at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:46
      2    Thread 0x72b39470 (LWP 4206) "QXcbEventReader" 0x76f21b90 in poll ()
        at ../sysdeps/unix/syscall-template.S:84
    

    Can anyone tell me whats going on in those gdb outputs? Are they even important or are they just there and we cant really do anything with them?



  • @Xenoshell
    Because you are using Python, not a standalone executable of your program compiled from C++, if you use gdb you have to gdb the Python executable, not your app running as a Python script. This means gdb probably is not of any interest to you, per se, for general debugging of your app; though it may give us some clues in this particular case.

    To clarify, for your app script completely. Just run gdb against Python without any mention of your qt5.py script. For the record, here is my output under Ubuntu not Pi:

    jon@ubuntu:~$ gdb python3
    Reading symbols from python3...(no debugging symbols found)...done.
    (gdb) run
    Starting program: /usr/bin/python3 
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    Python 3.5.3 (default, Nov 23 2017, 11:34:05) 
    [GCC 6.3.0 20170406] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    
    

    Does yours produce much the same? Does it only give the libpulse/libasound if a certain line is in your Python script, and not if it is removed, then you'd have an idea what is related to what? I wish you'd show what that line is now, because we no longer know whether you are enumerating available cameras or opening a camera?



  • @JNBarchan
    This is the whole output:

    blz@blz-desktop:~$ gdb python3
    GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
    Copyright (C) 2016 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "arm-linux-gnueabihf".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from python3...Reading symbols from /usr/lib/debug/.build-id/d7/14ad8d8b52ca34a8a81f10b4917027977b05ca.debug...done.
    done.
    (gdb) run
    Starting program: /usr/bin/python3 
    Cannot parse expression `.L1185 4@r4'.
    warning: Probes-based dynamic linker interface failed.
    Reverting to original interface.
    
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
    Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
    [GCC 5.4.0 20160609] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    
    

    My code always stops at self.cam = QCamera() otherwise it would also print 4 and not suddenly stop
    As a reminder, here is my code:

    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()
            print("4")
            self.caminfo = QCameraInfo(self.cam)
            self.camvfind = QCameraViewfinder()
            self.camvfindset = QCameraViewfinderSettings()
            self.cammode = self.cam.CaptureMode(2)
            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("4")
        cam.iniCamera()
        
        cam.startVid()
        
        sys.exit(app.exec_())
    
    


  • @Xenoshell
    I asked earlier:

    Does it only give the libpulse/libasound if a certain line is in your Python script, and not if it is removed, then you'd have an idea what is related to what?

    So, if I were you, under gdb, I'd try commenting in & commenting out the QCamera() line, and report whether your debugger only shows the libpulse error if & only if you have that line in there. then you'd know for sure whether QCamera() has anything to do with libpulse....

    I'd also try QCamera("video0") or QCamera("/dev/video0") or whatever it is, instead of plain QCamera(). I'd probably also try QCamera("rubbish"). These are all things for you to play with to try to understand just what causes the problem/hang, it's up to you....



  • @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



  • @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().



  • @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)



  • @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....



  • @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


  • Lifetime Qt Champion

    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 ?



  • @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.



  • @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??



  • @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)?



  • @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.



  • @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....



  • @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.



  • @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....



  • @JNBarchan
    Ok i am gonna do that.



  • @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



  • @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_())
    


  • @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?



  • @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



  • @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



  • 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."
    


  • @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



  • @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?



  • @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....



  • @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.



  • @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.... ?



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



  • @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....


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.