Issue with QCamera in PyQt6
RedHuli
redhuli.comments at gmail.com
Mon Nov 8 08:14:49 GMT 2021
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211108/7bf48bb9/attachment.htm>
More information about the PyQt
mailing list