Issue with QCamera in PyQt6

RedHuli redhuli.comments at gmail.com
Fri Nov 12 03:54:12 GMT 2021


Hi Phil,

Thanks so much for taking a moment to look at this.

I realized that the problem I was having was with the zsh shell on macOS. I
reverted back to the bash shell, ran the short script and had no
issues with the code.

Thanks,
Joshua Willman

On Tue, Nov 9, 2021 at 6:28 AM Phil Thompson <phil at riverbankcomputing.com>
wrote:

> On 08/11/2021 08:14, RedHuli wrote:
> > Hello,
> >
> > I was wondering if someone could help me with my issue. I want to
> > update my
> > code from PyQt5 to PyQt6. I need to use QCamera, but every time I do I
> > get
> > the following error:
> >
> > zsh: segmentation fault
> > /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
> > test_camera.py
> >
> >
> > No matter what I do, I still get an error. I've played around with
> > QMediaPlayer and QVideoWidget. I am not sure which new classes to use
> > in
> > PyQt6 to get the camera to play. Below is the minimum code (I believe)
> > should get the camera working:
> >
> >
> > # Import necessary modules
> > import sys
> > from PyQt6.QtWidgets import QApplication
> > from PyQt6.QtMultimedia import (QCamera, QMediaCaptureSession,
> > QMediaDevices
> > )
> > from PyQt6.QtMultimediaWidgets import QVideoWidget
> >
> > app = QApplication(sys.argv)
> >
> > video_widget = QVideoWidget()
> > video_widget.resize(640, 480)
> > video_widget.show()
> >
> > camera = QCamera(QMediaDevices.defaultVideoInput())
> > camera.start()
> >
> > mediaCaptureSession = QMediaCaptureSession()
> > mediaCaptureSession.setCamera(camera)
> > mediaCaptureSession.setVideoOutput(video_widget)
> >
> > sys.exit(app.exec())
> >
> >
> > Thanks for your help!
> >
> >
> > Joshua Willman
>
> It worked fine for me on macOS.
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211111/773a4094/attachment.htm>


More information about the PyQt mailing list